Content-Type: multipart/mixed; boundary="===============2391267221367245198==" MIME-Version: 1.0 From: Li Zhang Subject: [Accel-config] [PATCH v1 06/11] accel-config/test: Add test code of operation Zcompress16 Date: Tue, 17 May 2022 18:48:28 +0800 Message-ID: <20220517104833.1085245-7-li4.zhang@intel.com> In-Reply-To: 20220517104833.1085245-1-li4.zhang@intel.com To: accel-config@lists.01.org List-ID: --===============2391267221367245198== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add test code of operation Zcompress16 Signed-off-by: Li Zhang --- test/iaa.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++ test/iaa.h | 3 ++ test/iaa_prep.c | 13 ++++- test/iaa_test.c | 63 +++++++++++++++++++++++++ 4 files changed, 201 insertions(+), 1 deletion(-) diff --git a/test/iaa.c b/test/iaa.c index ea65541..7a964ff 100644 --- a/test/iaa.c +++ b/test/iaa.c @@ -17,6 +17,7 @@ #include "accel_test.h" #include "iaa.h" #include "algorithms/iaa_crc64.h" +#include "algorithms/iaa_zcompress.h" = static int init_crc64(struct task *tsk, int tflags, int opcode, unsigned l= ong src1_xfer_size) { @@ -34,6 +35,33 @@ static int init_crc64(struct task *tsk, int tflags, int = opcode, unsigned long sr return ACCTEST_STATUS_OK; } = +static int init_zcompress16(struct task *tsk, int tflags, int opcode, unsi= gned 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 aligned_alloc(ADDR_ALIGNMENT, src1_xfer_size); + if (!tsk->src1) + return -ENOMEM; + iaa_zcompress16_randomize_input(tsk->src1, tsk->pattern, src1_xfer_size); + + tsk->dst1 =3D aligned_alloc(ADDR_ALIGNMENT, src1_xfer_size * 2); + if (!tsk->dst1) + return -ENOMEM; + memset_pattern(tsk->dst1, 0, src1_xfer_size * 2); + + tsk->output =3D aligned_alloc(ADDR_ALIGNMENT, src1_xfer_size * 2); + if (!tsk->output) + return -ENOMEM; + memset_pattern(tsk->output, 0, src1_xfer_size * 2); + + tsk->iaa_max_dst_size =3D src1_xfer_size * 2; + + return ACCTEST_STATUS_OK; +} + /* this function is re-used by batch task */ int init_task(struct task *tsk, int tflags, int opcode, unsigned long src1= _xfer_size) { @@ -46,6 +74,9 @@ int init_task(struct task *tsk, int tflags, int opcode, u= nsigned long src1_xfer_ case IAX_OPCODE_CRC64: /* intentionally empty */ rc =3D init_crc64(tsk, tflags, opcode, src1_xfer_size); break; + case IAX_OPCODE_ZCOMPRESS16: + rc =3D init_zcompress16(tsk, tflags, opcode, src1_xfer_size); + break; } = if (rc !=3D ACCTEST_STATUS_OK) { @@ -150,6 +181,53 @@ int iaa_crc64_multi_task_nodes(struct acctest_context = *ctx) return ret; } = +static int iaa_wait_zcompress16(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("zcompress16 desc timeout\n"); + return ACCTEST_STATUS_TIMEOUT; + } + + return ACCTEST_STATUS_OK; +} + +int iaa_zcompress16_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; + + iaa_prep_zcompress16(tsk_node->tsk); + tsk_node =3D tsk_node->next; + } + + info("Submitted all zcompress16 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 iaa_wait_zcompress16(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 iaa_task_result_verify(struct task *tsk, int mismatch_expected) { @@ -163,6 +241,10 @@ int iaa_task_result_verify(struct task *tsk, int misma= tch_expected) switch (tsk->opcode) { case IAX_OPCODE_CRC64: ret =3D task_result_verify_crc64(tsk, mismatch_expected); + break; + case IAX_OPCODE_ZCOMPRESS16: + ret =3D task_result_verify_zcompress16(tsk, mismatch_expected); + break; } = if (ret =3D=3D ACCTEST_STATUS_OK) @@ -227,3 +309,44 @@ int task_result_verify_crc64(struct task *tsk, int mis= match_expected) = return -ENXIO; } + +int task_result_verify_zcompress16(struct task *tsk, int mismatch_expected) +{ + int i; + int rc; + int expected_len; + + if (mismatch_expected) + warn("invalid arg mismatch_expected for %d\n", tsk->opcode); + + expected_len =3D iaa_do_zcompress16(tsk->output, tsk->src1, tsk->xfer_siz= e); + rc =3D memcmp(tsk->dst1, tsk->output, expected_len); + + if (!mismatch_expected) { + if (expected_len - tsk->comp->iax_output_size) { + err("zcompress16 mismatch, exp len %d, act len %d\n", + expected_len, tsk->comp->iax_output_size); + + return -ENXIO; + } + if (rc) { + err("zcompress16 mismatch, memcmp rc %d\n", rc); + for (i =3D 0; i < (expected_len / 2); i++) { + printf("Exp[%d]=3D0x%04X, Act[%d]=3D0x%4X\n", + i, ((uint16_t *)tsk->output)[i], + i, ((uint16_t *)tsk->dst1)[i]); + } + + return -ENXIO; + } + return ACCTEST_STATUS_OK; + } + + /* mismatch_expected */ + if (rc) { + info("expected mismatch\n"); + return ACCTEST_STATUS_OK; + } + + return -ENXIO; +} diff --git a/test/iaa.h b/test/iaa.h index 40e1e29..9866d72 100644 --- a/test/iaa.h +++ b/test/iaa.h @@ -11,11 +11,14 @@ int init_task(struct task *tsk, int tflags, int opcode,= unsigned long src1_xfer_ = int iaa_noop_multi_task_nodes(struct acctest_context *ctx); int iaa_crc64_multi_task_nodes(struct acctest_context *ctx); +int iaa_zcompress16_multi_task_nodes(struct acctest_context *ctx); void iaa_prep_noop(struct task *tsk); void iaa_prep_crc64(struct task *tsk); +void iaa_prep_zcompress16(struct task *tsk); = int iaa_task_result_verify(struct task *tsk, int mismatch_expected); int iaa_task_result_verify_task_nodes(struct acctest_context *ctx, int mis= match_expected); int task_result_verify_crc64(struct task *tsk, int mismatch_expected); +int task_result_verify_zcompress16(struct task *tsk, int mismatch_expected= ); = #endif diff --git a/test/iaa_prep.c b/test/iaa_prep.c index 18e1c0d..fafe9f7 100644 --- a/test/iaa_prep.c +++ b/test/iaa_prep.c @@ -22,7 +22,7 @@ void iaa_prep_noop(struct task *tsk) = void iaa_prep_crc64(struct task *tsk) { - info("preparing descriptor for memcpy\n"); + info("preparing descriptor for crc64\n"); = acctest_prep_desc_common(tsk->desc, tsk->opcode, 0, (uint64_t)(tsk->src1), tsk->xfer_size, tsk->dflags); @@ -31,3 +31,14 @@ void iaa_prep_crc64(struct task *tsk) tsk->desc->iax_crc64_poly =3D tsk->iaa_crc64_poly; tsk->comp->status =3D 0; } + +void iaa_prep_zcompress16(struct task *tsk) +{ + info("preparing descriptor for zcompress16\n"); + + acctest_prep_desc_common(tsk->desc, tsk->opcode, (uint64_t)(tsk->dst1), + (uint64_t)(tsk->src1), tsk->xfer_size, tsk->dflags); + tsk->desc->completion_addr =3D (uint64_t)(tsk->comp); + tsk->desc->iax_max_dst_size =3D tsk->iaa_max_dst_size; + tsk->comp->status =3D 0; +} diff --git a/test/iaa_test.c b/test/iaa_test.c index d74817d..3c9f3c3 100644 --- a/test/iaa_test.c +++ b/test/iaa_test.c @@ -134,6 +134,63 @@ static int test_crc64(struct acctest_context *ctx, siz= e_t buf_size, int tflags, return rc; } = +static int test_zcompress(struct acctest_context *ctx, size_t buf_size, + int tflags, 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\n", + opcode, buf_size, tflags, num_desc); + + 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 all = the nodes*/ + tsk_node =3D ctx->multi_task_node; + while (tsk_node) { + 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_ZCOMPRESS16: + rc =3D iaa_zcompress16_multi_task_nodes(ctx); + if (rc !=3D ACCTEST_STATUS_OK) + return rc; + + /* Verification of all the nodes*/ + rc =3D iaa_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 *iaa; @@ -219,6 +276,12 @@ int main(int argc, char *argv[]) goto error; break; = + case IAX_OPCODE_ZCOMPRESS16: + rc =3D test_zcompress(iaa, buf_size, tflags, opcode, num_desc); + if (rc !=3D ACCTEST_STATUS_OK) + goto error; + break; + default: rc =3D -EINVAL; break; -- = 2.25.1 --===============2391267221367245198==--