accel-config:dsa_test Add no opcode opertion suooport
Tony Zhu
PATCH 1/1 accel-config:dsa_test Add no opcode opertion suooport
The No-op opertion performs no DMA opertion. Add the test support.
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
--- test/dsa.c | 30 ++++++++++++++++++++++++++++++ test/dsa.h | 5 +++++ test/dsa_test.c | 35 +++++++++++++++++++++++++++++++++++ test/prep.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+)
test/dsa.c +30 -0
@@ -554,6 +554,36 @@ void free_batch_task(struct batch_task *btsk)free (btsk); } +int dsa_wait_noop (struct dsa_context *ctx) +{ +struct dsa_completion_record *comp = ctx->single_task->comp; +int rc; + + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("noop desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +return DSA_STATUS_OK ; +} + +int dsa_noop (struct dsa_context *ctx) +{ +struct task *tsk = ctx->single_task; +int ret =DSA_STATUS_OK ; + + tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +//if ((tsk->test_flags & TEST_FLAGS_BOF) && ctx->bof) +// tsk->dflags |= IDXD_OP_FLAG_BOF; + +dsa_prep_noop (tsk); +dsa_desc_submit (ctx, tsk->desc); + ret =dsa_wait_noop (ctx); + +return ret; +} +int dsa_wait_batch (struct dsa_context *ctx) {int rc;
test/dsa.h +5 -0
@@ -217,6 +217,9 @@ struct task *__alloc_task(void);int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int dsa_noop (struct dsa_context *ctx); +int dsa_wait_noop (struct dsa_context *ctx); +int dsa_memcpy (struct dsa_context *ctx);int dsa_wait_memcpy (struct dsa_context *ctx);
@@ -232,6 +235,7 @@ int dsa_wait_compval(struct dsa_context *ctx);int dsa_dualcast (struct dsa_context *ctx);int dsa_wait_dualcast (struct dsa_context *ctx); +void dsa_prep_noop (struct task *tsk);void dsa_prep_memcpy (struct task *tsk);void dsa_reprep_memcpy (struct dsa_context *ctx);void dsa_prep_memfill (struct task *tsk);
@@ -256,6 +260,7 @@ int init_batch_task(struct batch_task *btsk, int task_num, int tflags, int opcode, unsigned long xfer_size, unsigned long dflags);void dsa_prep_batch (struct batch_task *btsk,unsigned long desc_flags); +void dsa_prep_batch_noop (struct batch_task *btsk);void dsa_prep_batch_memcpy (struct batch_task *btsk);void dsa_prep_batch_memfill (struct batch_task *btsk);void dsa_prep_batch_compare (struct batch_task *btsk);
test/dsa_test.c +35 -0
@@ -58,6 +58,9 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,return rc;switch (bopcode) { +case DSA_OPCODE_NOOP : +dsa_prep_batch_noop (ctx->batch_task); +break ;case DSA_OPCODE_MEMMOVE :dsa_prep_batch_memcpy (ctx->batch_task);break ;
@@ -157,6 +160,38 @@ int main(int argc, char *argv[]) }switch (opcode) { +case DSA_OPCODE_NOOP : { +struct task *tsk; + +info ("noop: len %#lx tflags %#x\n" , buf_size, tflags); + + rc =alloc_task (dsa); +if (rc !=DSA_STATUS_OK ) { +err ("noop: alloc task failed, rc=%d\n" , rc); + goto error; + } + + tsk = dsa->single_task; + rc =init_task (tsk, tflags, opcode, buf_size); +if (rc !=DSA_STATUS_OK ) { +err ("noop: init task failed\n" ); + goto error; + } + + rc =dsa_noop (dsa); +if (rc !=DSA_STATUS_OK ) { +err ("noop failed stat %d\n" , rc); + rc = -ENXIO ; +break ; + } + + rc =task_result_verify (tsk,0 ); +if (rc !=DSA_STATUS_OK ) + goto error; + +break ; + } +case DSA_OPCODE_BATCH :if (bsize > dsa->max_batch_size || bsize <2 ) {err ("invalid num descs: %d\n" , bsize);
test/prep.c +28 -0
@@ -30,6 +30,17 @@ void dsa_desc_submit(struct dsa_context *ctx, struct dsa_hw_desc *hw)usleep (10000 ); } +void dsa_prep_noop (struct task *tsk) +{ +info ("preparing descriptor for noop\n" ); + + tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +dsa_prep_desc_common (tsk->desc, tsk->opcode, (uint64_t )(tsk->dst1), + (uint64_t )(tsk->src1),0 , tsk->dflags); + tsk->desc->completion_addr = (uint64_t )(tsk->comp); + tsk->comp->status =0 ; +} +void dsa_prep_memcpy (struct task *tsk) {info ("preparing descriptor for memcpy\n" );
@@ -63,6 +74,23 @@ void dsa_reprep_memcpy(struct dsa_context *ctx)dsa_desc_submit (ctx, hw); } +void dsa_prep_batch_noop (struct batch_task *btsk) +{ +int i; +struct task *sub_task; + +uint32_t dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +for (i =0 ; i < btsk->task_num; i++) { + sub_task = &(btsk->sub_tasks[i]); +dsa_prep_desc_common (sub_task->desc, sub_task->opcode, + (uint64_t )(sub_task->dst1), + (uint64_t )(sub_task->src1), +0 , dflags); + sub_task->desc->completion_addr = (uint64_t )(sub_task->comp); + sub_task->comp->status =0 ; + } +} +/* Performs no error or bound checking */ void dsa_prep_batch_memcpy (struct batch_task *btsk) {
Signature · 1 line
2.27.0
Dave Jiang
On 8/25/2021 1:20 AM, Tony Zhu wrote:
subject: accel-config: dsa_test: Add noop opcode test support
Quoted 1 line
The No-op opertion performs no DMA opertion. Add the test support.
The NOOP operation performs a dummy DMA operation that does not initiate a transfer.
Quoted 29 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>--- test/dsa.c | 30 ++++++++++++++++++++++++++++++ test/dsa.h | 5 +++++ test/dsa_test.c | 35 +++++++++++++++++++++++++++++++++++ test/prep.c | 28 ++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+)test/dsa.c +12
-0@@ -554,6 +554,36 @@ void free_batch_task(struct batch_task *btsk)free (btsk); } +int dsa_wait_noop (struct dsa_context *ctx) +{ +struct dsa_completion_record *comp = ctx->single_task->comp; +int rc; + + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("noop desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +return DSA_STATUS_OK ;
test/dsa.c void free_batch_task(struct batch_task *btsk) · line 578
Quoted 10 lines
test/dsa.c +10
-0+} + +int dsa_noop (struct dsa_context *ctx) +{ +struct task *tsk = ctx->single_task; +int ret =DSA_STATUS_OK ; + + tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +//if ((tsk->test_flags & TEST_FLAGS_BOF) && ctx->bof) +// tsk->dflags |= IDXD_OP_FLAG_BOF;
Remove since commented out?
Quoted 140 lines
test/dsa.c +8
-0+ +dsa_prep_noop (tsk); +dsa_desc_submit (ctx, tsk->desc); + ret =dsa_wait_noop (ctx); + +return ret; +} +int dsa_wait_batch (struct dsa_context *ctx) {int rc;test/dsa.h +5
-0@@ -217,6 +217,9 @@ struct task *__alloc_task(void);int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int dsa_noop (struct dsa_context *ctx); +int dsa_wait_noop (struct dsa_context *ctx); +int dsa_memcpy (struct dsa_context *ctx);int dsa_wait_memcpy (struct dsa_context *ctx);@@ -232,6 +235,7 @@ int dsa_wait_compval(struct dsa_context *ctx);int dsa_dualcast (struct dsa_context *ctx);int dsa_wait_dualcast (struct dsa_context *ctx); +void dsa_prep_noop (struct task *tsk);void dsa_prep_memcpy (struct task *tsk);void dsa_reprep_memcpy (struct dsa_context *ctx);void dsa_prep_memfill (struct task *tsk);@@ -256,6 +260,7 @@ int init_batch_task(struct batch_task *btsk, int task_num, int tflags, int opcode, unsigned long xfer_size, unsigned long dflags);void dsa_prep_batch (struct batch_task *btsk,unsigned long desc_flags); +void dsa_prep_batch_noop (struct batch_task *btsk);void dsa_prep_batch_memcpy (struct batch_task *btsk);void dsa_prep_batch_memfill (struct batch_task *btsk);void dsa_prep_batch_compare (struct batch_task *btsk);test/dsa_test.c +35
-0@@ -58,6 +58,9 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,return rc;switch (bopcode) { +case DSA_OPCODE_NOOP : +dsa_prep_batch_noop (ctx->batch_task); +break ;case DSA_OPCODE_MEMMOVE :dsa_prep_batch_memcpy (ctx->batch_task);break ;@@ -157,6 +160,38 @@ int main(int argc, char *argv[]) }switch (opcode) { +case DSA_OPCODE_NOOP : { +struct task *tsk; + +info ("noop: len %#lx tflags %#x\n" , buf_size, tflags); + + rc =alloc_task (dsa); +if (rc !=DSA_STATUS_OK ) { +err ("noop: alloc task failed, rc=%d\n" , rc); + goto error; + } + + tsk = dsa->single_task; + rc =init_task (tsk, tflags, opcode, buf_size); +if (rc !=DSA_STATUS_OK ) { +err ("noop: init task failed\n" ); + goto error; + } + + rc =dsa_noop (dsa); +if (rc !=DSA_STATUS_OK ) { +err ("noop failed stat %d\n" , rc); + rc = -ENXIO ; +break ; + } + + rc =task_result_verify (tsk,0 ); +if (rc !=DSA_STATUS_OK ) + goto error; + +break ; + } +case DSA_OPCODE_BATCH :if (bsize > dsa->max_batch_size || bsize <2 ) {err ("invalid num descs: %d\n" , bsize);test/prep.c +28
-0@@ -30,6 +30,17 @@ void dsa_desc_submit(struct dsa_context *ctx, struct dsa_hw_desc *hw)usleep (10000 ); } +void dsa_prep_noop (struct task *tsk) +{ +info ("preparing descriptor for noop\n" ); + + tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +dsa_prep_desc_common (tsk->desc, tsk->opcode, (uint64_t )(tsk->dst1), + (uint64_t )(tsk->src1),0 , tsk->dflags); + tsk->desc->completion_addr = (uint64_t )(tsk->comp); + tsk->comp->status =0 ; +} +void dsa_prep_memcpy (struct task *tsk) {info ("preparing descriptor for memcpy\n" );@@ -63,6 +74,23 @@ void dsa_reprep_memcpy(struct dsa_context *ctx)dsa_desc_submit (ctx, hw); } +void dsa_prep_batch_noop (struct batch_task *btsk) +{ +int i; +struct task *sub_task; + +uint32_t dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +for (i =0 ; i < btsk->task_num; i++) { + sub_task = &(btsk->sub_tasks[i]); +dsa_prep_desc_common (sub_task->desc, sub_task->opcode, + (uint64_t )(sub_task->dst1), + (uint64_t )(sub_task->src1), +0 , dflags); + sub_task->desc->completion_addr = (uint64_t )(sub_task->comp); + sub_task->comp->status =0 ; + } +} +/* Performs no error or bound checking */ void dsa_prep_batch_memcpy (struct batch_task *btsk) {