Add opcode operation support in spec
Tony Zhu
v2 cover Add opcode operation support in spec
dsa_test only has memory opcode operations supported. Add the missing opcodes support to cover all DSA 1.0 operations.
Changelog:
v2:
- Modify DRAIN operation test - after memory move submission then do DRAIN operation
- break apart the rewrite and the adding of dif operations
- break init task into sub-functions for operations
- Remove "split drain multi task from noop multi task" which is merged in operation support
- Remove "add create and apply delta record result" which is merged in operation support
v3:
- Remove non-sense comment from patch "add 4 dif operations support"
Tony Zhu (7):
accel-config/test: add pattern2 to fill destination buffers accel-config/test: restructure init task to break data init into
sub-functions
accel-config/test: add drain operation support for single submission accel-config/test: add create and apply delta record operation support accel-config/test: add CRC Generation and Copy with CRC Generation
support
accel-config/test: add 4 dif operations support accel-config/test: add cache flush operation support
test/crc16_t10_lookup.h | 36 + test/dsa.c | 1519 +++++++++++++++++++++++++++++++++++++-- test/dsa.h | 102 +++ test/dsa_crc32.h | 351 +++++++++ test/dsa_test.c | 336 ++++++++- test/prep.c | 464 ++++++++++++ 6 files changed, 2759 insertions(+), 49 deletions(-) create mode 100644 test/crc16_t10_lookup.h create mode 100644 test/dsa_crc32.h
Signature · 1 line
2.27.0
Tony Zhu
PATCH v3 1/7 accel-config/test: add pattern2 to fill destination buffers
Use pattern to fill source buffers, use pattern2 to fill destination buffers. This will help to track/debug issue insteading of filling 0.
--- test/dsa.c | 7 +++---- test/dsa.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)
test/dsa.c +3 -4
@@ -287,6 +287,7 @@ int init_task(struct task *tsk, int tflags, int opcode,dbg ("initilizing single task %#lx\n" , tsk); tsk->pattern =0x0123456789abcdef ; + tsk->pattern2 =0xfedcba9876543210 ; tsk->opcode = opcode; tsk->test_flags = tflags; tsk->xfer_size = xfer_size;
@@ -321,8 +322,7 @@ int init_task(struct task *tsk, int tflags, int opcode, tsk->dst1 =aligned_alloc (1 <<12 , xfer_size);if (!tsk->dst1)return -ENOMEM ; -if (tflags &TEST_FLAGS_PREF ) -memset (tsk->dst1,0 , xfer_size); +memset_pattern (tsk->dst1, tsk->pattern2, xfer_size); }/* allocate memory: dst2*/
@@ -332,8 +332,7 @@ int init_task(struct task *tsk, int tflags, int opcode, tsk->dst2 =aligned_alloc (1 <<12 , xfer_size);if (!tsk->dst2)return -ENOMEM ; -if (tflags &TEST_FLAGS_PREF ) -memset (tsk->dst2,0 , xfer_size); +memset_pattern (tsk->dst2, tsk->pattern2, xfer_size); } dbg("Mem allocated: s1 %#lx s2 %#lx d1 %#lx d2 %#lx\n",
test/dsa.h +1 -0
@@ -57,6 +57,7 @@ struct task {void *dst1;void *dst2;uint64_t pattern; +uint64_t pattern2;uint64_t xfer_size;uint32_t dflags;int test_flags;
Signature · 1 line
2.27.0
Tony Zhu
PATCH v3 2/7 accel-config/test: restructure init task to break data init into sub-functions
In reply to Tony ZhuBreak data into sub-functions according opcodes. The init function will become large and large after we add all opcode support and difficult to track issues.
--- test/dsa.c | 164 ++++++++++++++++++++++++++++++++++++++++------------- test/dsa.h | 7 +++ 2 files changed, 133 insertions(+), 38 deletions(-)
test/dsa.c +126 -38
@@ -280,11 +280,9 @@ struct task *__alloc_task(void)return tsk; } -/* this function is re-used by batch task */ -int init_task (struct task *tsk,int tflags,int opcode, -unsigned long xfer_size) +int init_memcpy (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) { -dbg ("initilizing single task %#lx\n" , tsk); +unsigned long force_align =ADDR_ALIGNMENT ; tsk->pattern =0x0123456789abcdef ; tsk->pattern2 =0xfedcba9876543210 ;
@@ -292,47 +290,137 @@ int init_task(struct task *tsk, int tflags, int opcode, tsk->test_flags = tflags; tsk->xfer_size = xfer_size; -/* allocate memory: src1*/ -switch (opcode) { -case DSA_OPCODE_MEMMOVE :/* intentionally empty */ -case DSA_OPCODE_COMPARE :/* intentionally empty */ -case DSA_OPCODE_COMPVAL :/* intentionally empty */ -case DSA_OPCODE_DUALCAST : - tsk->src1 =malloc (xfer_size); -if (!tsk->src1) -return -ENOMEM ; -memset_pattern (tsk->src1, tsk->pattern, xfer_size); - } + tsk->src1 =aligned_alloc (force_align, xfer_size); +if (!tsk->src1) +return -ENOMEM ; +memset_pattern (tsk->src1, tsk->pattern, xfer_size); + + tsk->dst1 =aligned_alloc (force_align, xfer_size); +if (!tsk->dst1) +return -ENOMEM ; +memset_pattern (tsk->dst1, tsk->pattern2, xfer_size); + +return DSA_STATUS_OK ; +} + +int init_memfill (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; + + tsk->pattern =0x0123456789abcdef ; + tsk->pattern2 =0xfedcba9876543210 ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->dst1 =aligned_alloc (force_align, xfer_size); +if (!tsk->dst1) +return -ENOMEM ; +memset (tsk->dst1, tsk->pattern2, xfer_size); + +return DSA_STATUS_OK ; +} + +int init_compare (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->src1 =aligned_alloc (force_align, xfer_size); +if (!tsk->src1) +return -ENOMEM ; +memset_pattern (tsk->src1, tsk->pattern, xfer_size); + + tsk->src2 =aligned_alloc (force_align, xfer_size); +if (!tsk->src2) +return -ENOMEM ; +memset_pattern (tsk->src2, tsk->pattern, xfer_size); + +return DSA_STATUS_OK ; +} + +int init_compval (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->src1 =aligned_alloc (force_align, xfer_size); +if (!tsk->src1) +return -ENOMEM ; +memset_pattern (tsk->src1, tsk->pattern, xfer_size); + +return DSA_STATUS_OK ; +} + +int init_dualcast (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; + + tsk->pattern =0x0123456789abcdef ; + tsk->pattern2 =0xfedcba9876543210 ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->src1 =aligned_alloc (force_align, xfer_size); +if (!tsk->src1) +return -ENOMEM ; +memset_pattern (tsk->src1, tsk->pattern, xfer_size); + + tsk->dst1 =aligned_alloc (1 <<12 , xfer_size); +if (!tsk->dst1) +return -ENOMEM ; +memset_pattern (tsk->dst1, tsk->pattern2, xfer_size); + + tsk->dst2 =aligned_alloc (1 <<12 , xfer_size); +if (!tsk->dst2) +return -ENOMEM ; +memset_pattern (tsk->dst2, tsk->pattern2, xfer_size); + +return DSA_STATUS_OK ; +} + +/* this function is re-used by batch task */ +int init_task (struct task *tsk,int tflags,int opcode, +unsigned long xfer_size) +{ +int rc =0 ; + +dbg ("initilizing task %#lx\n" , tsk); -/* allocate memory: src2*/ switch (opcode) { +case DSA_OPCODE_MEMMOVE : + rc =init_memcpy (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_MEMFILL : + rc =init_memfill (tsk, tflags, opcode, xfer_size); +break ; +case DSA_OPCODE_COMPARE : - tsk->src2 =malloc (xfer_size); -if (!tsk->src2) -return -ENOMEM ; -memset_pattern (tsk->src2, tsk->pattern, xfer_size); - } + rc =init_compare (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_COMPVAL : + rc =init_compval (tsk, tflags, opcode, xfer_size); +break ; -/* allocate memory: dst1*/ -switch (opcode) { -case DSA_OPCODE_MEMMOVE :/* intentionally empty */ -case DSA_OPCODE_MEMFILL :/* intentionally empty */ case DSA_OPCODE_DUALCAST : -/* DUALCAST: dst1/dst2 lower 12 bits must be same */ - tsk->dst1 =aligned_alloc (1 <<12 , xfer_size); -if (!tsk->dst1) -return -ENOMEM ; -memset_pattern (tsk->dst1, tsk->pattern2, xfer_size); + rc =init_dualcast (tsk, tflags, opcode, xfer_size); +break ; } -/* allocate memory: dst2*/ -switch (opcode) { -case DSA_OPCODE_DUALCAST : -/* DUALCAST: dst1/dst2 lower 12 bits must be same */ - tsk->dst2 =aligned_alloc (1 <<12 , xfer_size); -if (!tsk->dst2) -return -ENOMEM ; -memset_pattern (tsk->dst2, tsk->pattern2, xfer_size); +if (rc !=DSA_STATUS_OK ) { +err ("init: opcode %d data failed\n" , opcode); +return rc; } dbg("Mem allocated: s1 %#lx s2 %#lx d1 %#lx d2 %#lx\n",
test/dsa.h +7 -0
@@ -41,6 +41,8 @@#define DSA_COMP_STAT_CODE_MASK 0x3F#define DSA_COMP_STAT_RW_MASK 0x80 +#define ADDR_ALIGNMENT 32 +/* helper macro to get lower 6 bits (ret code) from completion status */ #define stat_val (status) ((status) & DSA_COMP_STAT_CODE_MASK)
@@ -228,6 +230,11 @@ struct dsa_context *dsa_init(void);int dsa_alloc (struct dsa_context *ctx,int shared,int dev_id,int wq_id);int alloc_multiple_tasks (struct dsa_context *ctx,int num_itr);struct task *__alloc_task (void ); +int init_memcpy (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_memfill (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_compare (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_compval (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_dualcast (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);
Signature · 1 line
2.27.0
Tony Zhu
PATCH v3 3/7 accel-config/test: add drain operation support for single submission
In reply to Tony ZhuA Drain descriptor could not be included in a batch. It is treated as an unsupported operation type. Block on fault is reserved for Drain operation.
--- test/dsa.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ test/dsa.h | 4 ++++ test/dsa_test.c | 15 +++++++++++++++ test/prep.c | 16 ++++++++++++++++ 4 files changed, 82 insertions(+)
test/dsa.c +47 -0
@@ -397,6 +397,8 @@ int init_task(struct task *tsk, int tflags, int opcode,dbg ("initilizing task %#lx\n" , tsk);switch (opcode) { +/* After memory move, do drain opcode test */ +case DSA_OPCODE_DRAIN :case DSA_OPCODE_MEMMOVE : rc =init_memcpy (tsk, tflags, opcode, xfer_size);break ;
@@ -785,6 +787,51 @@ int dsa_wait_batch(struct batch_task *btsk)return DSA_STATUS_OK ; } +int dsa_wait_drain (struct dsa_context *ctx,struct task *tsk) +{ +struct dsa_completion_record *comp = tsk->comp; +int rc; + + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("drain desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +return DSA_STATUS_OK ; +} + +int dsa_drain_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { +/* Block on fault is reserved for Drain */ + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; + +dsa_prep_drain (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + tsk_node = ctx->multi_task_node; +info ("Submitted all drain jobs\n" ); + +while (tsk_node) { + ret =dsa_wait_drain (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , + tsk_node->tsk->desc, tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} +int dsa_wait_memcpy (struct dsa_context *ctx,struct task *tsk) {struct dsa_hw_desc *desc = tsk->desc;
test/dsa.h +4 -0
@@ -241,6 +241,9 @@ int init_task(struct task *tsk, int tflags, int opcode,int dsa_noop_multi_task_nodes (struct dsa_context *ctx);int dsa_wait_noop (struct dsa_context *ctx,struct task *tsk); +int dsa_drain_multi_task_nodes (struct dsa_context *ctx); +int dsa_wait_drain (struct dsa_context *ctx,struct task *tsk); +int dsa_memcpy_multi_task_nodes (struct dsa_context *ctx);int dsa_wait_memcpy (struct dsa_context *ctx,struct task *tsk);
@@ -257,6 +260,7 @@ int dsa_dualcast_multi_task_nodes(struct dsa_context *ctx);int dsa_wait_dualcast (struct dsa_context *ctx,struct task *tsk);void dsa_prep_noop (struct task *tsk); +void dsa_prep_drain (struct task *tsk);void dsa_prep_memcpy (struct task *tsk);void dsa_reprep_memcpy (struct dsa_context *ctx,struct task *tsk);void dsa_prep_memfill (struct task *tsk);
test/dsa_test.c +15 -0
@@ -221,6 +221,20 @@ static int test_memory(struct dsa_context *ctx, size_t buf_size, }switch (opcode) { +case DSA_OPCODE_DRAIN : + rc =dsa_memcpy_multi_task_nodes (ctx); +if (rc !=DSA_STATUS_OK ) +return rc; + + rc =dsa_drain_multi_task_nodes (ctx); +if (rc !=DSA_STATUS_OK ) +return rc; + + rc =task_result_verify_task_nodes (ctx,0 ); +if (rc !=DSA_STATUS_OK ) +return rc; +break ; +case DSA_OPCODE_MEMMOVE : rc =dsa_memcpy_multi_task_nodes (ctx);if (rc !=DSA_STATUS_OK )
@@ -420,6 +434,7 @@ int main(int argc, char *argv[]) goto error;break ; +case DSA_OPCODE_DRAIN :case DSA_OPCODE_MEMMOVE :case DSA_OPCODE_MEMFILL :case DSA_OPCODE_COMPARE :
test/prep.c +16 -0
@@ -41,10 +41,26 @@ void dsa_prep_noop(struct task *tsk) tsk->comp->status =0 ; } +void dsa_prep_drain (struct task *tsk) +{ +info ("preparing descriptor for drain\n" ); + +if (tsk->opcode ==DSA_OPCODE_MEMMOVE ) + tsk->opcode =DSA_OPCODE_DRAIN ; + +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" ); +if (tsk->opcode ==DSA_OPCODE_DRAIN ) + tsk->opcode =DSA_OPCODE_MEMMOVE ; +dsa_prep_desc_common (tsk->desc, tsk->opcode, (uint64_t )(tsk->dst1), (uint64_t )(tsk->src1), tsk->xfer_size, tsk->dflags); tsk->desc->completion_addr = (uint64_t )(tsk->comp);
Signature · 1 line
2.27.0
Tony Zhu
PATCH v3 4/7 accel-config/test: add create and apply delta record operation support
In reply to Tony ZhuDo creating delta record and then do apply delta operation test. Delta Record Address is the address of a delta record that was created by a Create Delta Record operation that completed with Result equal to 1.
--- test/dsa.c | 170 ++++++++++++++++++++++++++++++++++++++++++++++++ test/dsa.h | 16 +++++ test/dsa_test.c | 126 ++++++++++++++++++++++++++++++++++- test/prep.c | 116 +++++++++++++++++++++++++++++++++ 4 files changed, 427 insertions(+), 1 deletion(-)
test/dsa.c +170 -0
@@ -388,6 +388,41 @@ int init_dualcast(struct task *tsk, int tflags, int opcode, unsigned long xfer_sreturn DSA_STATUS_OK ; } +int init_cr_delta (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned long delta_size; + + tsk->pattern =0x1234 ; + tsk->pattern2 =0x1233 ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->src1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src1) +return -ENOMEM ; +memset_pattern (tsk->src1, tsk->pattern, tsk->xfer_size); + + tsk->src2 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src2) +return -ENOMEM ; +memset_pattern (tsk->src2, tsk->pattern2, tsk->xfer_size); + delta_size =2 * xfer_size; + + tsk->delta1 =aligned_alloc (force_align, delta_size); +if (!tsk->delta1) +return -ENOMEM ; + +if (opcode ==DSA_OPCODE_AP_DELTA ) { + tsk->dst1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->dst1) +return -ENOMEM ; + } + +return DSA_STATUS_OK ; +} +/* this function is re-used by batch task */ int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size)
@@ -418,6 +453,11 @@ int init_task(struct task *tsk, int tflags, int opcode,case DSA_OPCODE_DUALCAST : rc =init_dualcast (tsk, tflags, opcode, xfer_size);break ; + +case DSA_OPCODE_AP_DELTA : +case DSA_OPCODE_CR_DELTA : + rc =init_cr_delta (tsk, tflags, opcode, xfer_size); +break ; }if (rc !=DSA_STATUS_OK ) {
@@ -1115,6 +1155,118 @@ int dsa_dualcast_multi_task_nodes(struct dsa_context *ctx)return ret; } +int dsa_wait_cr_delta (struct dsa_context *ctx,struct task *tsk) +{ +struct dsa_hw_desc *desc = tsk->desc; +struct dsa_completion_record *comp = tsk->comp; +int rc; + +again: + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("memcpy desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +/* re-submit if PAGE_FAULT reported by HW && BOF is off */ +if (stat_val (comp->status) ==DSA_COMP_PAGE_FAULT_NOBOF && + !(desc->flags &IDXD_OP_FLAG_BOF )) { +dsa_reprep_cr_delta (ctx, tsk); + goto again; + } + +return DSA_STATUS_OK ; +} + +int dsa_cr_delta_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_cr_delta (tsk_node->tsk); + tsk_node = tsk_node->next; + } + +info ("Submitted all cr delta jobs\n" ); + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { + ret =dsa_wait_cr_delta (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , + tsk_node->tsk->desc, tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } + +return ret; +} + +int dsa_wait_ap_delta (struct dsa_context *ctx,struct task *tsk) +{ +struct dsa_hw_desc *desc = tsk->desc; +struct dsa_completion_record *comp = tsk->comp; +int rc; + +again: + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("memcpy desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +/* re-submit if PAGE_FAULT reported by HW && BOF is off */ +if (stat_val (comp->status) ==DSA_COMP_PAGE_FAULT_NOBOF && + !(desc->flags &IDXD_OP_FLAG_BOF )) { +dsa_reprep_ap_delta (ctx, tsk); + goto again; + } + +return DSA_STATUS_OK ; +} + +int dsa_ap_delta_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_ap_delta (tsk_node->tsk); + tsk_node = tsk_node->next; + } + +info ("Submitted all ap delta jobs\n" ); + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { + ret =dsa_wait_ap_delta (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , + tsk_node->tsk->desc, tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } + +return ret; +} +/* mismatch_expected: expect mismatched buffer with success status 0x1 */ int task_result_verify (struct task *tsk,int mismatch_expected) {
@@ -1141,6 +1293,9 @@ int task_result_verify(struct task *tsk, int mismatch_expected)case DSA_OPCODE_DUALCAST : rc =task_result_verify_dualcast (tsk, mismatch_expected);return rc; +case DSA_OPCODE_AP_DELTA : + rc =task_result_verify_ap_delta (tsk, mismatch_expected); +return rc; }info ("test with op %d passed\n" , tsk->opcode);
@@ -1260,6 +1415,21 @@ int task_result_verify_dualcast(struct task *tsk, int mismatch_expected)return DSA_STATUS_OK ; } +int task_result_verify_ap_delta (struct task *tsk,int mismatch_expected) +{ +int rc; +int data_size = (tsk->comp->status ==DSA_COMP_SUCCESS ) ? + tsk->desc->xfer_size : tsk->comp->bytes_completed; + + rc =memcmp ((unsigned char *)tsk->desc->dst_addr, + (unsigned char *)tsk->desc->src2_addr, data_size); +if (rc) { +err ("apply delta mismatch, memcmp rc %d\n" , rc); +return -ENXIO ; + } +return DSA_STATUS_OK ; +} +int batch_result_verify (struct batch_task *btsk,int bof) {uint8_t core_stat, sub_stat;
test/dsa.h +16 -0
@@ -43,6 +43,7 @@#define ADDR_ALIGNMENT 32 +#define MIN_DELTA_RECORD_SIZE 80/* helper macro to get lower 6 bits (ret code) from completion status */ #define stat_val (status) ((status) & DSA_COMP_STAT_CODE_MASK)
@@ -58,6 +59,7 @@ struct task {void *src2;void *dst1;void *dst2; +void *delta1;uint64_t pattern;uint64_t pattern2;uint64_t xfer_size;
@@ -235,6 +237,7 @@ int init_memfill(struct task *tsk, int tflags, int opcode, unsigned long xfer_siint init_compare (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_compval (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_dualcast (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_cr_delta (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);
@@ -259,6 +262,12 @@ int dsa_wait_compval(struct dsa_context *ctx, struct task *tsk);int dsa_dualcast_multi_task_nodes (struct dsa_context *ctx);int dsa_wait_dualcast (struct dsa_context *ctx,struct task *tsk); +int dsa_cr_delta_multi_task_nodes (struct dsa_context *ctx); +int dsa_wait_cr_delta (struct dsa_context *ctx,struct task *tsk); + +int dsa_ap_delta_multi_task_nodes (struct dsa_context *ctx); +int dsa_wait_ap_delta (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_noop (struct task *tsk);void dsa_prep_drain (struct task *tsk);void dsa_prep_memcpy (struct task *tsk);
@@ -271,6 +280,10 @@ void dsa_prep_compval(struct task *tsk);void dsa_reprep_compval (struct dsa_context *ctx,struct task *tsk);void dsa_prep_dualcast (struct task *tsk);void dsa_reprep_dualcast (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_cr_delta (struct task *tsk); +void dsa_reprep_cr_delta (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_ap_delta (struct task *tsk); +void dsa_reprep_ap_delta (struct dsa_context *ctx,struct task *tsk);int task_result_verify (struct task *tsk,int mismatch_expected);int task_result_verify_task_nodes (struct dsa_context *ctx,int mismatch_expected);
@@ -279,6 +292,7 @@ int task_result_verify_memfill(struct task *tsk, int mismatch_expected);int task_result_verify_compare (struct task *tsk,int mismatch_expected);int task_result_verify_compval (struct task *tsk,int mismatch_expected);int task_result_verify_dualcast (struct task *tsk,int mismatch_expected); +int task_result_verify_ap_delta (struct task *tsk,int mismatch_expected);int batch_result_verify (struct batch_task *btsk,int bof);int alloc_batch_task (struct dsa_context *ctx,unsigned int task_num,int num_itr);
@@ -292,6 +306,8 @@ void dsa_prep_batch_memfill(struct batch_task *btsk);void dsa_prep_batch_compare (struct batch_task *btsk);void dsa_prep_batch_compval (struct batch_task *btsk);void dsa_prep_batch_dualcast (struct batch_task *btsk); +void dsa_prep_batch_cr_delta (struct batch_task *btsk); +void dsa_prep_batch_ap_delta (struct batch_task *btsk);int dsa_wait_batch (struct batch_task *btsk);void dsa_free (struct dsa_context *ctx);
test/dsa_test.c +125 -1
157 lines not on this page · raw message
test/prep.c +116 -0
122 lines not on this page · raw message
Signature · 1 line
2.27.0
Tony Zhu
PATCH v3 5/7 accel-config/test: add CRC Generation and Copy with CRC Generation support
In reply to Tony ZhuThe CRC Generation operation computes the CRC on memory at the Source Address.The Copy with CRC Generation operation copies memory from the Source Address to the Destination Address and computes the CRC on the data copied. The completion record format for Copy with CRC Generation is identical to the format for CRC Generation.
--- test/crc16_t10_lookup.h | 36 +++++ test/dsa.c | 315 ++++++++++++++++++++++++++++++++++++ test/dsa.h | 23 +++ test/dsa_crc32.h | 351 ++++++++++++++++++++++++++++++++++++++++ test/dsa_test.c | 81 ++++++++++ test/prep.c | 97 +++++++++++ 6 files changed, 903 insertions(+) create mode 100644 test/crc16_t10_lookup.h create mode 100644 test/dsa_crc32.h
test/crc16_t10_lookup.h new file +36 -0
@@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright(c) 2022 Intel Corporation. All rights reserved. */ +static const unsigned short t10_dif_crc_table[256 ] = { +0x0000 ,0x8BB7 ,0x9CD9 ,0x176E ,0xB205 ,0x39B2 ,0x2EDC ,0xA56B , +0xEFBD ,0x640A ,0x7364 ,0xF8D3 ,0x5DB8 ,0xD60F ,0xC161 ,0x4AD6 , +0x54CD ,0xDF7A ,0xC814 ,0x43A3 ,0xE6C8 ,0x6D7F ,0x7A11 ,0xF1A6 , +0xBB70 ,0x30C7 ,0x27A9 ,0xAC1E ,0x0975 ,0x82C2 ,0x95AC ,0x1E1B , +0xA99A ,0x222D ,0x3543 ,0xBEF4 ,0x1B9F ,0x9028 ,0x8746 ,0x0CF1 , +0x4627 ,0xCD90 ,0xDAFE ,0x5149 ,0xF422 ,0x7F95 ,0x68FB ,0xE34C , +0xFD57 ,0x76E0 ,0x618E ,0xEA39 ,0x4F52 ,0xC4E5 ,0xD38B ,0x583C , +0x12EA ,0x995D ,0x8E33 ,0x0584 ,0xA0EF ,0x2B58 ,0x3C36 ,0xB781 , +0xD883 ,0x5334 ,0x445A ,0xCFED ,0x6A86 ,0xE131 ,0xF65F ,0x7DE8 , +0x373E ,0xBC89 ,0xABE7 ,0x2050 ,0x853B ,0x0E8C ,0x19E2 ,0x9255 , +0x8C4E ,0x07F9 ,0x1097 ,0x9B20 ,0x3E4B ,0xB5FC ,0xA292 ,0x2925 , +0x63F3 ,0xE844 ,0xFF2A ,0x749D ,0xD1F6 ,0x5A41 ,0x4D2F ,0xC698 , +0x7119 ,0xFAAE ,0xEDC0 ,0x6677 ,0xC31C ,0x48AB ,0x5FC5 ,0xD472 , +0x9EA4 ,0x1513 ,0x027D ,0x89CA ,0x2CA1 ,0xA716 ,0xB078 ,0x3BCF , +0x25D4 ,0xAE63 ,0xB90D ,0x32BA ,0x97D1 ,0x1C66 ,0x0B08 ,0x80BF , +0xCA69 ,0x41DE ,0x56B0 ,0xDD07 ,0x786C ,0xF3DB ,0xE4B5 ,0x6F02 , +0x3AB1 ,0xB106 ,0xA668 ,0x2DDF ,0x88B4 ,0x0303 ,0x146D ,0x9FDA , +0xD50C ,0x5EBB ,0x49D5 ,0xC262 ,0x6709 ,0xECBE ,0xFBD0 ,0x7067 , +0x6E7C ,0xE5CB ,0xF2A5 ,0x7912 ,0xDC79 ,0x57CE ,0x40A0 ,0xCB17 , +0x81C1 ,0x0A76 ,0x1D18 ,0x96AF ,0x33C4 ,0xB873 ,0xAF1D ,0x24AA , +0x932B ,0x189C ,0x0FF2 ,0x8445 ,0x212E ,0xAA99 ,0xBDF7 ,0x3640 , +0x7C96 ,0xF721 ,0xE04F ,0x6BF8 ,0xCE93 ,0x4524 ,0x524A ,0xD9FD , +0xC7E6 ,0x4C51 ,0x5B3F ,0xD088 ,0x75E3 ,0xFE54 ,0xE93A ,0x628D , +0x285B ,0xA3EC ,0xB482 ,0x3F35 ,0x9A5E ,0x11E9 ,0x0687 ,0x8D30 , +0xE232 ,0x6985 ,0x7EEB ,0xF55C ,0x5037 ,0xDB80 ,0xCCEE ,0x4759 , +0x0D8F ,0x8638 ,0x9156 ,0x1AE1 ,0xBF8A ,0x343D ,0x2353 ,0xA8E4 , +0xB6FF ,0x3D48 ,0x2A26 ,0xA191 ,0x04FA ,0x8F4D ,0x9823 ,0x1394 , +0x5942 ,0xD2F5 ,0xC59B ,0x4E2C ,0xEB47 ,0x60F0 ,0x779E ,0xFC29 , +0x4BA8 ,0xC01F ,0xD771 ,0x5CC6 ,0xF9AD ,0x721A ,0x6574 ,0xEEC3 , +0xA415 ,0x2FA2 ,0x38CC ,0xB37B ,0x1610 ,0x9DA7 ,0x8AC9 ,0x017E , +0x1F65 ,0x94D2 ,0x83BC ,0x080B ,0xAD60 ,0x26D7 ,0x31B9 ,0xBA0E , +0xF0D8 ,0x7B6F ,0x6C01 ,0xE7B6 ,0x42DD ,0xC96A ,0xDE04 ,0x55B3 +};
test/dsa.c +315 -0
351 lines not on this page · raw message
test/dsa.h +23 -0
@@ -41,6 +41,11 @@#define DSA_COMP_STAT_CODE_MASK 0x3F#define DSA_COMP_STAT_RW_MASK 0x80 +/* CRC Flags */ +#define READ_CRC_SEED ((unsigned long)(1 << 16)) +#define BYPASS_CRC_INV_REF ((unsigned long)(1 << 17)) +#define BYPASS_DATA_REF ((unsigned long)(1 << 18)) +#define ADDR_ALIGNMENT 32#define MIN_DELTA_RECORD_SIZE 80
@@ -65,6 +70,8 @@ struct task {uint64_t xfer_size;uint32_t dflags;int test_flags; +int crc_seed; +unsigned long long *crc_seed_addr; };struct task_node {
@@ -238,6 +245,8 @@ int init_compare(struct task *tsk, int tflags, int opcode, unsigned long xfer_siint init_compval (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_dualcast (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_cr_delta (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_crcgen (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_copy_crc (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);
@@ -268,6 +277,12 @@ int dsa_wait_cr_delta(struct dsa_context *ctx, struct task *tsk);int dsa_ap_delta_multi_task_nodes (struct dsa_context *ctx);int dsa_wait_ap_delta (struct dsa_context *ctx,struct task *tsk); +int dsa_crcgen_multi_task_nodes (struct dsa_context *ctx); +int dsa_wait_crcgen (struct dsa_context *ctx,struct task *tsk); + +int dsa_crc_copy_multi_task_nodes (struct dsa_context *ctx); +int dsa_wait_crc_copy (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_noop (struct task *tsk);void dsa_prep_drain (struct task *tsk);void dsa_prep_memcpy (struct task *tsk);
@@ -284,6 +299,10 @@ void dsa_prep_cr_delta(struct task *tsk);void dsa_reprep_cr_delta (struct dsa_context *ctx,struct task *tsk);void dsa_prep_ap_delta (struct task *tsk);void dsa_reprep_ap_delta (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_crcgen (struct task *tsk); +void dsa_reprep_crcgen (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_crc_copy (struct task *tsk); +void dsa_reprep_crc_copy (struct dsa_context *ctx,struct task *tsk);int task_result_verify (struct task *tsk,int mismatch_expected);int task_result_verify_task_nodes (struct dsa_context *ctx,int mismatch_expected);
@@ -293,6 +312,8 @@ int task_result_verify_compare(struct task *tsk, int mismatch_expected);int task_result_verify_compval (struct task *tsk,int mismatch_expected);int task_result_verify_dualcast (struct task *tsk,int mismatch_expected);int task_result_verify_ap_delta (struct task *tsk,int mismatch_expected); +int task_result_verify_crcgen (struct task *tsk,int mismatch_expected); +int task_result_verify_crc_copy (struct task *tsk,int mismatch_expected);int batch_result_verify (struct batch_task *btsk,int bof);int alloc_batch_task (struct dsa_context *ctx,unsigned int task_num,int num_itr);
@@ -308,6 +329,8 @@ void dsa_prep_batch_compval(struct batch_task *btsk);void dsa_prep_batch_dualcast (struct batch_task *btsk);void dsa_prep_batch_cr_delta (struct batch_task *btsk);void dsa_prep_batch_ap_delta (struct batch_task *btsk); +void dsa_prep_batch_crcgen (struct batch_task *btsk); +void dsa_prep_batch_crc_copy (struct batch_task *btsk);int dsa_wait_batch (struct batch_task *btsk);void dsa_free (struct dsa_context *ctx);
test/dsa_crc32.h new file +351 -0
351 lines not on this page · raw message
test/dsa_test.c +81 -0
99 lines not on this page · raw message
test/prep.c +97 -0
103 lines not on this page · raw message
Signature · 1 line
2.27.0
Tony Zhu
PATCH v3 6/7 accel-config/test: add 4 dif operations support
In reply to Tony ZhuAdd Data Integrity Field (DIF) check, insert, strip, and update operation support while transferring data.
--- test/dsa.c | 727 ++++++++++++++++++++++++++++++++++++++++++++++++ test/dsa.h | 44 +++ test/dsa_test.c | 104 +++++++ test/prep.c | 189 +++++++++++++ 4 files changed, 1064 insertions(+)
test/dsa.c +727 -0
@@ -23,6 +23,35 @@ unsigned int ms_timeout = 5000;int debug_logging;static int umwait_support; +unsigned int dif_blk_arr[] = {512 ,520 ,4096 ,4104 }; + +int get_dif_blksz_flg (unsigned long xfer_size) +{ +int blk_idx_flg =3 ; + +while (blk_idx_flg) { +if (xfer_size % dif_blk_arr[blk_idx_flg] ==0 ) +break ; + blk_idx_flg--; + } +return blk_idx_flg; +} + +unsigned long get_blks (unsigned long xfer_size) +{ +int blk_idx_flg =3 ; +unsigned long num_blks; + +while (blk_idx_flg) { +if (xfer_size % dif_blk_arr[blk_idx_flg] ==0 ) +break ; + blk_idx_flg--; + } + + num_blks = xfer_size / dif_blk_arr[blk_idx_flg]; +return num_blks; +} +static inline void cpuid (unsigned int *eax,unsigned int *ebx,unsigned int *ecx,unsigned int *edx) {
@@ -477,6 +506,196 @@ int init_copy_crc(struct task *tsk, int tflags, int opcode, unsigned long xfer_sreturn DSA_STATUS_OK ; } +int init_dif_check (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long buf_size; +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned char *src; +unsigned int dif_reftag; +unsigned int dif_apptag; +unsigned int dif_guardtag; +unsigned long blks =0 ; +unsigned long i; +unsigned long dif_size; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + + buf_size = tsk->xfer_size / blks; +/* 8 bytes for inclusion of tags */ + tsk->xfer_size +=8 * blks; + tsk->src1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src1) +return -ENOMEM ; + src = (unsigned char *)tsk->src1; + dif_reftag = tsk->reftag; + dif_apptag = tsk->apptag; + +for (i =1 ; i <= blks; i++) { + dif_size = (buf_size +8 ) * (i -1 ); +memset_pattern ((src + dif_size), tsk->pattern, buf_size); + dif_guardtag =dsa_calculate_crc_t10dif ((src + dif_size), buf_size,0 ); + src[buf_size +DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >>8 ) &0xFF ; + src[buf_size +DIF_BLK_GRD_2 + dif_size] = dif_guardtag &0xFF ; + src[buf_size +DIF_APP_TAG_1 + dif_size] = (dif_apptag >>8 ) &0xFF ; + src[buf_size +DIF_APP_TAG_2 + dif_size] = (dif_apptag) &0xFF ; + src[buf_size +DIF_REF_TAG_1 + dif_size] = (dif_reftag >>24 ) &0xFF ; + src[buf_size +DIF_REF_TAG_2 + dif_size] = (dif_reftag >>16 ) &0xFF ; + src[buf_size +DIF_REF_TAG_3 + dif_size] = (dif_reftag >>8 ) &0xFF ; + src[buf_size +DIF_REF_TAG_4 + dif_size] = dif_reftag &0xFF ; + dif_reftag++; + } + +return DSA_STATUS_OK ; +} + +int init_dif_ins (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned long blks =0 ; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + + tsk->src1 =aligned_alloc (force_align, xfer_size); +if (!tsk->src1) +return -ENOMEM ; +memset_pattern (tsk->src1, tsk->pattern, xfer_size); + blks =get_blks (xfer_size); + xfer_size +=8 * blks; + tsk->dst1 =aligned_alloc (force_align, xfer_size); +if (!tsk->dst1) +return -ENOMEM ; + +return DSA_STATUS_OK ; +} + +int init_dif_strp (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long buf_size; +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned char *src; +unsigned int dif_reftag; +unsigned int dif_apptag; +unsigned int dif_guardtag; +unsigned long blks =0 ; +unsigned long i; +unsigned long dif_size; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + buf_size = tsk->xfer_size / blks; +/* 8 bytes for inclusion of tags */ + tsk->xfer_size +=8 * blks; + tsk->src1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src1) +return -ENOMEM ; + + src = (unsigned char *)tsk->src1; + dif_reftag = tsk->reftag; + dif_apptag = tsk->apptag; + +for (i =1 ; i <= blks; i++) { + dif_size = (buf_size +8 ) * (i -1 ); +memset_pattern ((src + dif_size), tsk->pattern, buf_size); + dif_guardtag =dsa_calculate_crc_t10dif ((src + dif_size), buf_size,0 ); + src[buf_size +DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >>8 ) &0xFF ; + src[buf_size +DIF_BLK_GRD_2 + dif_size] = dif_guardtag &0xFF ; + src[buf_size +DIF_APP_TAG_1 + dif_size] = (dif_apptag >>8 ) &0xFF ; + src[buf_size +DIF_APP_TAG_2 + dif_size] = (dif_apptag) &0xFF ; + src[buf_size +DIF_REF_TAG_1 + dif_size] = (dif_reftag >>24 ) &0xFF ; + src[buf_size +DIF_REF_TAG_2 + dif_size] = (dif_reftag >>16 ) &0xFF ; + src[buf_size +DIF_REF_TAG_3 + dif_size] = (dif_reftag >>8 ) &0xFF ; + src[buf_size +DIF_REF_TAG_4 + dif_size] = dif_reftag &0xFF ; + dif_reftag++; + } + + tsk->dst1 =aligned_alloc (force_align, tsk->xfer_size -8 * blks); +if (!tsk->dst1) +return -ENOMEM ; + +return DSA_STATUS_OK ; +} + +int init_dif_updt (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long buf_size; +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned char *src; +unsigned int dif_reftag; +unsigned int dif_apptag; +unsigned int dif_guardtag; +unsigned long blks =0 ; +unsigned long i; +unsigned long dif_size; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + buf_size = tsk->xfer_size / blks; + tsk->xfer_size +=8 * blks; + tsk->src1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src1) +return -ENOMEM ; + + src = (unsigned char *)tsk->src1; + dif_reftag = tsk->reftag; + dif_apptag = tsk->apptag; + +for (i =1 ; i <= blks; i++) { + dif_size = (buf_size +8 ) * (i -1 ); +memset_pattern ((src + dif_size), tsk->pattern, buf_size); + dif_guardtag =dsa_calculate_crc_t10dif ((src + dif_size), buf_size,0 ); + src[buf_size +DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >>8 ) &0xFF ; + src[buf_size +DIF_BLK_GRD_2 + dif_size] = dif_guardtag &0xFF ; + src[buf_size +DIF_APP_TAG_1 + dif_size] = (dif_apptag >>8 ) &0xFF ; + src[buf_size +DIF_APP_TAG_2 + dif_size] = (dif_apptag) &0xFF ; + src[buf_size +DIF_REF_TAG_1 + dif_size] = (dif_reftag >>24 ) &0xFF ; + src[buf_size +DIF_REF_TAG_2 + dif_size] = (dif_reftag >>16 ) &0xFF ; + src[buf_size +DIF_REF_TAG_3 + dif_size] = (dif_reftag >>8 ) &0xFF ; + src[buf_size +DIF_REF_TAG_4 + dif_size] = dif_reftag &0xFF ; + } + tsk->dst1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->dst1) +return -ENOMEM ; + +return DSA_STATUS_OK ; +} +/* this function is re-used by batch task */ int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size)
@@ -520,6 +739,22 @@ int init_task(struct task *tsk, int tflags, int opcode,case DSA_OPCODE_COPY_CRC : rc =init_copy_crc (tsk, tflags, opcode, xfer_size);break ; + +case DSA_OPCODE_DIF_CHECK : + rc =init_dif_check (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_DIF_INS : + rc =init_dif_ins (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_DIF_STRP : + rc =init_dif_strp (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_DIF_UPDT : + rc =init_dif_updt (tsk, tflags, opcode, xfer_size); +break ; }if (rc !=DSA_STATUS_OK ) {
@@ -1441,6 +1676,158 @@ int dsa_crc_copy_multi_task_nodes(struct dsa_context *ctx)return ret; } +int dsa_wait_dif (struct dsa_context *ctx,struct task *tsk) +{ +struct dsa_hw_desc *desc = tsk->desc; +struct dsa_completion_record *comp = tsk->comp; +int rc; + +again: + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("DIF desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +/* re-submit if PAGE_FAULT reported by HW && BOF is off */ +if (stat_val (comp->status) ==DSA_COMP_PAGE_FAULT_NOBOF && + !(desc->flags &IDXD_OP_FLAG_BOF )) { +task_result_verify (tsk,0 ); +dsa_reprep_dif (ctx, tsk); + goto again; + } + +return DSA_STATUS_OK ; +} + +int dsa_dif_check_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_check (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + +info ("Submitted all dif check jobs\n" ); + tsk_node = ctx->multi_task_node; +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} + +int dsa_dif_ins_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_insert (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + tsk_node = ctx->multi_task_node; +info ("Submitted all dif insert jobs\n" ); +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} + +int dsa_dif_strp_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_strip (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + +info ("Submitted all dif strp jobs\n" ); + tsk_node = ctx->multi_task_node; +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } + +return ret; +} + +int dsa_dif_updt_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_update (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + tsk_node = ctx->multi_task_node; + +info ("Submitted all dif update jobs\n" ); +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} +/* mismatch_expected: expect mismatched buffer with success status 0x1 */ int task_result_verify (struct task *tsk,int mismatch_expected) {
@@ -1476,6 +1863,19 @@ int task_result_verify(struct task *tsk, int mismatch_expected)case DSA_OPCODE_COPY_CRC : rc =task_result_verify_crc_copy (tsk, mismatch_expected);return rc; +case DSA_OPCODE_DIF_INS : + rc =task_result_verify_dif (tsk, tsk->xfer_size, mismatch_expected); + rc =task_result_verify_dif_tags (tsk, tsk->xfer_size); +return rc; +case DSA_OPCODE_DIF_STRP : + rc =task_result_verify_dif (tsk, tsk->xfer_size -8 * tsk->blks, + mismatch_expected); +return rc; +case DSA_OPCODE_DIF_UPDT : + rc =task_result_verify_dif (tsk, tsk->xfer_size -8 * tsk->blks, + mismatch_expected); + rc =task_result_verify_dif_tags (tsk, tsk->xfer_size -8 * tsk->blks); +return rc; }info ("test with op %d passed\n" , tsk->opcode);
@@ -1745,6 +2145,333 @@ int task_result_verify_crc_copy(struct task *tsk, int mismatch_expected)return DSA_STATUS_OK ; } +/** +* This function calculates the CRC16 T10 checksum for the DIF descriptors. +* @param *buffer pointer to the data buffer. +* @param len size of the buffer. +* +**/ +uint16_t dsa_calculate_crc_t10dif (unsigned char *buffer,size_t len,int flags) +{ +unsigned short crc; +unsigned int i =0 ; + + crc = (flags &DIF_INVERT_CRC_SEED ) ?0xFFFF :0 ; + +for (i =0 ; i < len; i++) + crc = (crc <<8 ) ^ t10_dif_crc_table[((crc >>8 ) ^ buffer[i]) &0xff ]; + +return (flags &DIF_INVERT_CRC_RESULT ) ? ~crc : crc; +} + +static int task_result_verify_dif_page_fault (struct task *tsk,unsigned long xfer_size, +int mismatch_expected) +{ +struct dsa_hw_desc *hw = tsk->desc; +int rc =0 ; +unsigned char *src1 = (unsigned char *)hw->src_addr; +unsigned char *dst1 = (unsigned char *)hw->dst_addr; +unsigned long i, blks; + +if (tsk->comp->status ==0x16 || xfer_size ==0 ) +/* This check need to be removed for GNR-SP. Its a know bug in SPR-SP +* https://hsdes.intel.com/appstore/article/#/22010927356 +* [SPR][No Fix] For DIF operations, RTL should consider 'computed transfer size' +* when determining overlapping buffer conditions +*/ +return DSA_STATUS_OK ; + +info ("Partial DIF Src and Dest Check Ongoing\n" ); + +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) { + blks = xfer_size / dif_blk_arr[tsk->blk_idx_flg]; +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[dif_blk_arr[tsk->blk_idx_flg] * i], + &dst1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + dif_blk_arr[tsk->blk_idx_flg]); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_STRP ) { + blks = xfer_size / (dif_blk_arr[tsk->blk_idx_flg] +8 ); +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + &dst1[dif_blk_arr[tsk->blk_idx_flg] * i], + dif_blk_arr[tsk->blk_idx_flg]); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_UPDT ) { + blks = xfer_size / (dif_blk_arr[tsk->blk_idx_flg] +8 ); +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + &dst1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + dif_blk_arr[tsk->blk_idx_flg]); + } + +if (rc) { +err ("dif mismatch dst1, memcmp rc %d\n" , rc); +return -ENXIO ; + } + +return DSA_STATUS_OK ; +} + +int task_result_verify_dif (struct task *tsk,unsigned long xfer_size,int mismatch_expected) +{ +int rc; +unsigned long i; +unsigned long blks = tsk->blks; +unsigned long buf_size = dif_blk_arr[tsk->blk_idx_flg]; +unsigned char *src1 = (unsigned char *)tsk->src1; +unsigned char *dst1 = (unsigned char *)tsk->dst1; + +if (tsk->comp->status ==DSA_COMP_PAGE_FAULT_NOBOF || + tsk->comp->status ==DSA_COMP_PAGE_FAULT_IR || + tsk->comp->status ==0x83 ) { + rc =task_result_verify_dif_page_fault (tsk, tsk->comp->bytes_completed,0 ); +info ("Partial DIF Src and Dest Checking Done\n" ); +if (!rc) +return DSA_STATUS_OK ; + } + +/* This check need to be removed for GNR-SP. Its a know bug in SPR-SP +* https://hsdes.intel.com/appstore/article/#/22010927356 +* [SPR][No Fix] For DIF operations, RTL should consider 'computed transfer size' +* when determining overlapping buffer conditions +*/ +if (tsk->comp->status ==0x16 ) +return DSA_STATUS_OK ; + +info ("Checking Src & Dst buffers\n" ); +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) { +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[buf_size * i], &dst1[(buf_size +8 ) * i], buf_size); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_STRP ) { +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(buf_size +8 ) * i], &dst1[buf_size * i], buf_size); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_UPDT ) { +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(buf_size +8 ) * i], &dst1[(buf_size +8 ) * i], buf_size); + } + +if (rc) { +err ("dif mismatch dst1, memcmp rc %d\n" , rc); +return -ENXIO ; + } + +return DSA_STATUS_OK ; +} + +static int task_result_verify_dif_tags_page_fault (struct task *tsk,unsigned long xfer_size) +{ +struct dsa_hw_desc *hw = tsk->desc; +unsigned long blks; +unsigned long buf_size; +unsigned char *dst1 = (uint8_t *)hw->dst_addr; +unsigned char *src1 = (uint8_t *)hw->src_addr; +unsigned long g_count =0 ; +unsigned long a_count =0 ; +unsigned long r_count =0 ; +unsigned short dif_apptag =0 ; +unsigned long dif_reftag =0 ; +unsigned int dif_guardtag =0 ; +unsigned char tmp_buf; +unsigned char dst_tag; +unsigned long i; + +info ("Checking Partial DIF Tags\n" ); +/* This check need to be removed for GNR-SP. Its a know bug in SPR-SP +* https://hsdes.intel.com/appstore/article/#/22010927356 +* [SPR][No Fix] For DIF operations, RTL should consider 'computed transfer size' +* when determining overlapping buffer conditions +*/ +if (tsk->comp->status ==0x16 || xfer_size ==0 ) +return DSA_STATUS_OK ; + +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + blks = xfer_size / dif_blk_arr[tsk->blk_idx_flg]; +else + blks = xfer_size / (dif_blk_arr[tsk->blk_idx_flg] +8 ); + +switch (tsk->opcode) { +case DSA_OPCODE_DIF_INS : + dif_reftag = hw->ins_ref_tag_seed; + dif_apptag = hw->ins_app_tag_seed; +break ; + +case DSA_OPCODE_DIF_CHECK : +case DSA_OPCODE_DIF_STRP : + dif_reftag = hw->chk_ref_tag_seed; + dif_apptag = hw->chk_app_tag_seed; +break ; + +case DSA_OPCODE_DIF_UPDT : + dif_reftag = hw->dest_ref_tag_seed; + dif_apptag = hw->dest_app_tag_seed; +break ; + } + + buf_size = dif_blk_arr[tsk->blk_idx_flg]; +for (i =0 ; i < blks; i++) { +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + buf_size * i), + buf_size,0 ); +else + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + (buf_size +8 ) * i), + buf_size,0 ); + + dst_tag = dst1[buf_size +DIF_BLK_GRD_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_guardtag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_BLK_GRD_2 + (buf_size +8 ) * i]; + tmp_buf = dif_guardtag &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>24 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>16 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_3 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_4 + (buf_size +8 ) * i]; + tmp_buf = dif_reftag &0xff ; +if (tmp_buf != dst_tag) + r_count++; + +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + dif_reftag++; + } + +if (g_count || a_count || r_count) +err ("Tag Errors Found g: %ld a: %ld r: %ld\n" , g_count, a_count, r_count); +else +info ("All Tags Validated\n" , g_count, a_count, r_count); + +return DSA_STATUS_OK ; +} + +int task_result_verify_dif_tags (struct task *tsk,unsigned long xfer_size) +{ +int rc; +unsigned long blks; +unsigned long buf_size; +unsigned char *dst1 = (unsigned char *)tsk->dst1; +unsigned char *src1 = (unsigned char *)tsk->src1; +unsigned long g_count =0 ; +unsigned long a_count =0 ; +unsigned long r_count =0 ; +unsigned int dif_reftag = tsk->reftag; +unsigned int dif_apptag = tsk->apptag; +unsigned int dif_guardtag =0 ; +unsigned char tmp_buf; +unsigned char dst_tag; +unsigned long i; + +info ("compsts: %x\n" , tsk->comp->status); +if (tsk->comp->status ==0x83 || + tsk->comp->status ==DSA_COMP_PAGE_FAULT_NOBOF || + tsk->comp->status ==DSA_COMP_PAGE_FAULT_IR ) { + rc =task_result_verify_dif_tags_page_fault (tsk, tsk->comp->bytes_completed); +info ("Partial DIF Tags Checking Done\n" ); +if (!rc) +return DSA_STATUS_OK ; + } + +info ("Checking All Tags\n" ); +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + blks = xfer_size / dif_blk_arr[tsk->blk_idx_flg]; +else + blks = tsk->blks; + + buf_size = dif_blk_arr[tsk->blk_idx_flg]; + tsk->reftag =0xABBA ; + tsk->apptag =0xFACE ; + +for (i =0 ; i < blks; i++) { +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + (buf_size) * i), + buf_size,0 ); +else + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + (buf_size +8 ) * i), + buf_size,0 ); + + dst_tag = dst1[buf_size +DIF_BLK_GRD_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_guardtag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_BLK_GRD_2 + (buf_size +8 ) * i]; + tmp_buf = dif_guardtag &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>24 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>16 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_3 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_4 + (buf_size +8 ) * i]; + tmp_buf = dif_reftag &0xff ; +if (tmp_buf != dst_tag) + r_count++; + +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + dif_reftag++; + } + +if (g_count || a_count || r_count) +err ("Tag Errors Found g: %ld a: %ld r: %ld\n" , g_count, a_count, r_count); +else +info ("All Tags Validated\n" , g_count, a_count, r_count); + +return DSA_STATUS_OK ; +} +int batch_result_verify (struct batch_task *btsk,int bof) {uint8_t core_stat, sub_stat;
test/dsa.h +44 -0
96 lines not on this page · raw message
test/dsa_test.c +104 -0
122 lines not on this page · raw message
test/prep.c +189 -0
201 lines not on this page · raw message
Signature · 1 line
2.27.0
Dave Jiang
[Accel-config] Re: [PATCH v3 6/7] accel-config/test: add 4 dif operations support
Quoted 2 lines · Tony Zhu
Add Data Integrity Field (DIF) check, insert, strip, and update operation support while transferring data.
I saw several comments where it says it's an issue for SPR but not GNR?
1. Please remove internal links (i.e. HSD) because this is going public.
2. Please refer to external hw errata doc if any.
3. Easiest way to deal with this is check DSA/IAX hw version via libaccel-config call and only set these changes < version 2.
Quoted 1,227 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>--- test/dsa.c | 727 ++++++++++++++++++++++++++++++++++++++++++++++++ test/dsa.h | 44 +++ test/dsa_test.c | 104 +++++++ test/prep.c | 189 +++++++++++++ 4 files changed, 1064 insertions(+)test/dsa.c +727
-0@@ -23,6 +23,35 @@ unsigned int ms_timeout = 5000;int debug_logging;static int umwait_support; +unsigned int dif_blk_arr[] = {512 ,520 ,4096 ,4104 }; + +int get_dif_blksz_flg (unsigned long xfer_size) +{ +int blk_idx_flg =3 ; + +while (blk_idx_flg) { +if (xfer_size % dif_blk_arr[blk_idx_flg] ==0 ) +break ; + blk_idx_flg--; + } +return blk_idx_flg; +} + +unsigned long get_blks (unsigned long xfer_size) +{ +int blk_idx_flg =3 ; +unsigned long num_blks; + +while (blk_idx_flg) { +if (xfer_size % dif_blk_arr[blk_idx_flg] ==0 ) +break ; + blk_idx_flg--; + } + + num_blks = xfer_size / dif_blk_arr[blk_idx_flg]; +return num_blks; +} +static inline void cpuid (unsigned int *eax,unsigned int *ebx,unsigned int *ecx,unsigned int *edx) {@@ -477,6 +506,196 @@ int init_copy_crc(struct task *tsk, int tflags, int opcode, unsigned long xfer_sreturn DSA_STATUS_OK ; } +int init_dif_check (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long buf_size; +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned char *src; +unsigned int dif_reftag; +unsigned int dif_apptag; +unsigned int dif_guardtag; +unsigned long blks =0 ; +unsigned long i; +unsigned long dif_size; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + + buf_size = tsk->xfer_size / blks; +/* 8 bytes for inclusion of tags */ + tsk->xfer_size +=8 * blks; + tsk->src1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src1) +return -ENOMEM ; + src = (unsigned char *)tsk->src1; + dif_reftag = tsk->reftag; + dif_apptag = tsk->apptag; + +for (i =1 ; i <= blks; i++) { + dif_size = (buf_size +8 ) * (i -1 ); +memset_pattern ((src + dif_size), tsk->pattern, buf_size); + dif_guardtag =dsa_calculate_crc_t10dif ((src + dif_size), buf_size,0 ); + src[buf_size +DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >>8 ) &0xFF ; + src[buf_size +DIF_BLK_GRD_2 + dif_size] = dif_guardtag &0xFF ; + src[buf_size +DIF_APP_TAG_1 + dif_size] = (dif_apptag >>8 ) &0xFF ; + src[buf_size +DIF_APP_TAG_2 + dif_size] = (dif_apptag) &0xFF ; + src[buf_size +DIF_REF_TAG_1 + dif_size] = (dif_reftag >>24 ) &0xFF ; + src[buf_size +DIF_REF_TAG_2 + dif_size] = (dif_reftag >>16 ) &0xFF ; + src[buf_size +DIF_REF_TAG_3 + dif_size] = (dif_reftag >>8 ) &0xFF ; + src[buf_size +DIF_REF_TAG_4 + dif_size] = dif_reftag &0xFF ; + dif_reftag++; + } + +return DSA_STATUS_OK ; +} + +int init_dif_ins (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned long blks =0 ; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + + tsk->src1 =aligned_alloc (force_align, xfer_size); +if (!tsk->src1) +return -ENOMEM ; +memset_pattern (tsk->src1, tsk->pattern, xfer_size); + blks =get_blks (xfer_size); + xfer_size +=8 * blks; + tsk->dst1 =aligned_alloc (force_align, xfer_size); +if (!tsk->dst1) +return -ENOMEM ; + +return DSA_STATUS_OK ; +} + +int init_dif_strp (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long buf_size; +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned char *src; +unsigned int dif_reftag; +unsigned int dif_apptag; +unsigned int dif_guardtag; +unsigned long blks =0 ; +unsigned long i; +unsigned long dif_size; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + buf_size = tsk->xfer_size / blks; +/* 8 bytes for inclusion of tags */ + tsk->xfer_size +=8 * blks; + tsk->src1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src1) +return -ENOMEM ; + + src = (unsigned char *)tsk->src1; + dif_reftag = tsk->reftag; + dif_apptag = tsk->apptag; + +for (i =1 ; i <= blks; i++) { + dif_size = (buf_size +8 ) * (i -1 ); +memset_pattern ((src + dif_size), tsk->pattern, buf_size); + dif_guardtag =dsa_calculate_crc_t10dif ((src + dif_size), buf_size,0 ); + src[buf_size +DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >>8 ) &0xFF ; + src[buf_size +DIF_BLK_GRD_2 + dif_size] = dif_guardtag &0xFF ; + src[buf_size +DIF_APP_TAG_1 + dif_size] = (dif_apptag >>8 ) &0xFF ; + src[buf_size +DIF_APP_TAG_2 + dif_size] = (dif_apptag) &0xFF ; + src[buf_size +DIF_REF_TAG_1 + dif_size] = (dif_reftag >>24 ) &0xFF ; + src[buf_size +DIF_REF_TAG_2 + dif_size] = (dif_reftag >>16 ) &0xFF ; + src[buf_size +DIF_REF_TAG_3 + dif_size] = (dif_reftag >>8 ) &0xFF ; + src[buf_size +DIF_REF_TAG_4 + dif_size] = dif_reftag &0xFF ; + dif_reftag++; + } + + tsk->dst1 =aligned_alloc (force_align, tsk->xfer_size -8 * blks); +if (!tsk->dst1) +return -ENOMEM ; + +return DSA_STATUS_OK ; +} + +int init_dif_updt (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long buf_size; +unsigned long force_align =ADDR_ALIGNMENT ; +unsigned char *src; +unsigned int dif_reftag; +unsigned int dif_apptag; +unsigned int dif_guardtag; +unsigned long blks =0 ; +unsigned long i; +unsigned long dif_size; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->apptag =0xFACE ; + tsk->reftag =0xABBA ; + + tsk->blk_idx_flg =get_dif_blksz_flg (tsk->xfer_size); + blks = tsk->xfer_size / dif_blk_arr[tsk->blk_idx_flg]; + tsk->blks = blks; + buf_size = tsk->xfer_size / blks; + tsk->xfer_size +=8 * blks; + tsk->src1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->src1) +return -ENOMEM ; + + src = (unsigned char *)tsk->src1; + dif_reftag = tsk->reftag; + dif_apptag = tsk->apptag; + +for (i =1 ; i <= blks; i++) { + dif_size = (buf_size +8 ) * (i -1 ); +memset_pattern ((src + dif_size), tsk->pattern, buf_size); + dif_guardtag =dsa_calculate_crc_t10dif ((src + dif_size), buf_size,0 ); + src[buf_size +DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >>8 ) &0xFF ; + src[buf_size +DIF_BLK_GRD_2 + dif_size] = dif_guardtag &0xFF ; + src[buf_size +DIF_APP_TAG_1 + dif_size] = (dif_apptag >>8 ) &0xFF ; + src[buf_size +DIF_APP_TAG_2 + dif_size] = (dif_apptag) &0xFF ; + src[buf_size +DIF_REF_TAG_1 + dif_size] = (dif_reftag >>24 ) &0xFF ; + src[buf_size +DIF_REF_TAG_2 + dif_size] = (dif_reftag >>16 ) &0xFF ; + src[buf_size +DIF_REF_TAG_3 + dif_size] = (dif_reftag >>8 ) &0xFF ; + src[buf_size +DIF_REF_TAG_4 + dif_size] = dif_reftag &0xFF ; + } + tsk->dst1 =aligned_alloc (force_align, tsk->xfer_size); +if (!tsk->dst1) +return -ENOMEM ; + +return DSA_STATUS_OK ; +} +/* this function is re-used by batch task */ int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size)@@ -520,6 +739,22 @@ int init_task(struct task *tsk, int tflags, int opcode,case DSA_OPCODE_COPY_CRC : rc =init_copy_crc (tsk, tflags, opcode, xfer_size);break ; + +case DSA_OPCODE_DIF_CHECK : + rc =init_dif_check (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_DIF_INS : + rc =init_dif_ins (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_DIF_STRP : + rc =init_dif_strp (tsk, tflags, opcode, xfer_size); +break ; + +case DSA_OPCODE_DIF_UPDT : + rc =init_dif_updt (tsk, tflags, opcode, xfer_size); +break ; }if (rc !=DSA_STATUS_OK ) {@@ -1441,6 +1676,158 @@ int dsa_crc_copy_multi_task_nodes(struct dsa_context *ctx)return ret; } +int dsa_wait_dif (struct dsa_context *ctx,struct task *tsk) +{ +struct dsa_hw_desc *desc = tsk->desc; +struct dsa_completion_record *comp = tsk->comp; +int rc; + +again: + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("DIF desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +/* re-submit if PAGE_FAULT reported by HW && BOF is off */ +if (stat_val (comp->status) ==DSA_COMP_PAGE_FAULT_NOBOF && + !(desc->flags &IDXD_OP_FLAG_BOF )) { +task_result_verify (tsk,0 ); +dsa_reprep_dif (ctx, tsk); + goto again; + } + +return DSA_STATUS_OK ; +} + +int dsa_dif_check_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_check (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + +info ("Submitted all dif check jobs\n" ); + tsk_node = ctx->multi_task_node; +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} + +int dsa_dif_ins_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_insert (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + tsk_node = ctx->multi_task_node; +info ("Submitted all dif insert jobs\n" ); +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} + +int dsa_dif_strp_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_strip (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + +info ("Submitted all dif strp jobs\n" ); + tsk_node = ctx->multi_task_node; +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } + +return ret; +} + +int dsa_dif_updt_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_dif_update (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + tsk_node = ctx->multi_task_node; + +info ("Submitted all dif update jobs\n" ); +while (tsk_node) { + ret =dsa_wait_dif (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , tsk_node->tsk->desc, + tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} +/* mismatch_expected: expect mismatched buffer with success status 0x1 */ int task_result_verify (struct task *tsk,int mismatch_expected) {@@ -1476,6 +1863,19 @@ int task_result_verify(struct task *tsk, int mismatch_expected)case DSA_OPCODE_COPY_CRC : rc =task_result_verify_crc_copy (tsk, mismatch_expected);return rc; +case DSA_OPCODE_DIF_INS : + rc =task_result_verify_dif (tsk, tsk->xfer_size, mismatch_expected); + rc =task_result_verify_dif_tags (tsk, tsk->xfer_size); +return rc; +case DSA_OPCODE_DIF_STRP : + rc =task_result_verify_dif (tsk, tsk->xfer_size -8 * tsk->blks, + mismatch_expected); +return rc; +case DSA_OPCODE_DIF_UPDT : + rc =task_result_verify_dif (tsk, tsk->xfer_size -8 * tsk->blks, + mismatch_expected); + rc =task_result_verify_dif_tags (tsk, tsk->xfer_size -8 * tsk->blks); +return rc; }info ("test with op %d passed\n" , tsk->opcode);@@ -1745,6 +2145,333 @@ int task_result_verify_crc_copy(struct task *tsk, int mismatch_expected)return DSA_STATUS_OK ; } +/** +* This function calculates the CRC16 T10 checksum for the DIF descriptors. +* @param *buffer pointer to the data buffer. +* @param len size of the buffer. +* +**/ +uint16_t dsa_calculate_crc_t10dif (unsigned char *buffer,size_t len,int flags) +{ +unsigned short crc; +unsigned int i =0 ; + + crc = (flags &DIF_INVERT_CRC_SEED ) ?0xFFFF :0 ; + +for (i =0 ; i < len; i++) + crc = (crc <<8 ) ^ t10_dif_crc_table[((crc >>8 ) ^ buffer[i]) &0xff ]; + +return (flags &DIF_INVERT_CRC_RESULT ) ? ~crc : crc; +} + +static int task_result_verify_dif_page_fault (struct task *tsk,unsigned long xfer_size, +int mismatch_expected) +{ +struct dsa_hw_desc *hw = tsk->desc; +int rc =0 ; +unsigned char *src1 = (unsigned char *)hw->src_addr; +unsigned char *dst1 = (unsigned char *)hw->dst_addr; +unsigned long i, blks; + +if (tsk->comp->status ==0x16 || xfer_size ==0 ) +/* This check need to be removed for GNR-SP. Its a know bug in SPR-SP +* https://hsdes.intel.com/appstore/article/#/22010927356 +* [SPR][No Fix] For DIF operations, RTL should consider 'computed transfer size' +* when determining overlapping buffer conditions +*/ +return DSA_STATUS_OK ; + +info ("Partial DIF Src and Dest Check Ongoing\n" ); + +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) { + blks = xfer_size / dif_blk_arr[tsk->blk_idx_flg]; +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[dif_blk_arr[tsk->blk_idx_flg] * i], + &dst1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + dif_blk_arr[tsk->blk_idx_flg]); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_STRP ) { + blks = xfer_size / (dif_blk_arr[tsk->blk_idx_flg] +8 ); +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + &dst1[dif_blk_arr[tsk->blk_idx_flg] * i], + dif_blk_arr[tsk->blk_idx_flg]); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_UPDT ) { + blks = xfer_size / (dif_blk_arr[tsk->blk_idx_flg] +8 ); +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + &dst1[(dif_blk_arr[tsk->blk_idx_flg] +8 ) * i], + dif_blk_arr[tsk->blk_idx_flg]); + } + +if (rc) { +err ("dif mismatch dst1, memcmp rc %d\n" , rc); +return -ENXIO ; + } + +return DSA_STATUS_OK ; +} + +int task_result_verify_dif (struct task *tsk,unsigned long xfer_size,int mismatch_expected) +{ +int rc; +unsigned long i; +unsigned long blks = tsk->blks; +unsigned long buf_size = dif_blk_arr[tsk->blk_idx_flg]; +unsigned char *src1 = (unsigned char *)tsk->src1; +unsigned char *dst1 = (unsigned char *)tsk->dst1; + +if (tsk->comp->status ==DSA_COMP_PAGE_FAULT_NOBOF || + tsk->comp->status ==DSA_COMP_PAGE_FAULT_IR || + tsk->comp->status ==0x83 ) { + rc =task_result_verify_dif_page_fault (tsk, tsk->comp->bytes_completed,0 ); +info ("Partial DIF Src and Dest Checking Done\n" ); +if (!rc) +return DSA_STATUS_OK ; + } + +/* This check need to be removed for GNR-SP. Its a know bug in SPR-SP +* https://hsdes.intel.com/appstore/article/#/22010927356 +* [SPR][No Fix] For DIF operations, RTL should consider 'computed transfer size' +* when determining overlapping buffer conditions +*/ +if (tsk->comp->status ==0x16 ) +return DSA_STATUS_OK ; + +info ("Checking Src & Dst buffers\n" ); +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) { +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[buf_size * i], &dst1[(buf_size +8 ) * i], buf_size); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_STRP ) { +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(buf_size +8 ) * i], &dst1[buf_size * i], buf_size); + } + +if (tsk->opcode ==DSA_OPCODE_DIF_UPDT ) { +for (i =0 ; i < blks; i++) + rc =memcmp (&src1[(buf_size +8 ) * i], &dst1[(buf_size +8 ) * i], buf_size); + } + +if (rc) { +err ("dif mismatch dst1, memcmp rc %d\n" , rc); +return -ENXIO ; + } + +return DSA_STATUS_OK ; +} + +static int task_result_verify_dif_tags_page_fault (struct task *tsk,unsigned long xfer_size) +{ +struct dsa_hw_desc *hw = tsk->desc; +unsigned long blks; +unsigned long buf_size; +unsigned char *dst1 = (uint8_t *)hw->dst_addr; +unsigned char *src1 = (uint8_t *)hw->src_addr; +unsigned long g_count =0 ; +unsigned long a_count =0 ; +unsigned long r_count =0 ; +unsigned short dif_apptag =0 ; +unsigned long dif_reftag =0 ; +unsigned int dif_guardtag =0 ; +unsigned char tmp_buf; +unsigned char dst_tag; +unsigned long i; + +info ("Checking Partial DIF Tags\n" ); +/* This check need to be removed for GNR-SP. Its a know bug in SPR-SP +* https://hsdes.intel.com/appstore/article/#/22010927356 +* [SPR][No Fix] For DIF operations, RTL should consider 'computed transfer size' +* when determining overlapping buffer conditions +*/ +if (tsk->comp->status ==0x16 || xfer_size ==0 ) +return DSA_STATUS_OK ; + +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + blks = xfer_size / dif_blk_arr[tsk->blk_idx_flg]; +else + blks = xfer_size / (dif_blk_arr[tsk->blk_idx_flg] +8 ); + +switch (tsk->opcode) { +case DSA_OPCODE_DIF_INS : + dif_reftag = hw->ins_ref_tag_seed; + dif_apptag = hw->ins_app_tag_seed; +break ; + +case DSA_OPCODE_DIF_CHECK : +case DSA_OPCODE_DIF_STRP : + dif_reftag = hw->chk_ref_tag_seed; + dif_apptag = hw->chk_app_tag_seed; +break ; + +case DSA_OPCODE_DIF_UPDT : + dif_reftag = hw->dest_ref_tag_seed; + dif_apptag = hw->dest_app_tag_seed; +break ; + } + + buf_size = dif_blk_arr[tsk->blk_idx_flg]; +for (i =0 ; i < blks; i++) { +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + buf_size * i), + buf_size,0 ); +else + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + (buf_size +8 ) * i), + buf_size,0 ); + + dst_tag = dst1[buf_size +DIF_BLK_GRD_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_guardtag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_BLK_GRD_2 + (buf_size +8 ) * i]; + tmp_buf = dif_guardtag &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>24 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>16 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_3 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_4 + (buf_size +8 ) * i]; + tmp_buf = dif_reftag &0xff ; +if (tmp_buf != dst_tag) + r_count++; + +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + dif_reftag++; + } + +if (g_count || a_count || r_count) +err ("Tag Errors Found g: %ld a: %ld r: %ld\n" , g_count, a_count, r_count); +else +info ("All Tags Validated\n" , g_count, a_count, r_count); + +return DSA_STATUS_OK ; +} + +int task_result_verify_dif_tags (struct task *tsk,unsigned long xfer_size) +{ +int rc; +unsigned long blks; +unsigned long buf_size; +unsigned char *dst1 = (unsigned char *)tsk->dst1; +unsigned char *src1 = (unsigned char *)tsk->src1; +unsigned long g_count =0 ; +unsigned long a_count =0 ; +unsigned long r_count =0 ; +unsigned int dif_reftag = tsk->reftag; +unsigned int dif_apptag = tsk->apptag; +unsigned int dif_guardtag =0 ; +unsigned char tmp_buf; +unsigned char dst_tag; +unsigned long i; + +info ("compsts: %x\n" , tsk->comp->status); +if (tsk->comp->status ==0x83 || + tsk->comp->status ==DSA_COMP_PAGE_FAULT_NOBOF || + tsk->comp->status ==DSA_COMP_PAGE_FAULT_IR ) { + rc =task_result_verify_dif_tags_page_fault (tsk, tsk->comp->bytes_completed); +info ("Partial DIF Tags Checking Done\n" ); +if (!rc) +return DSA_STATUS_OK ; + } + +info ("Checking All Tags\n" ); +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + blks = xfer_size / dif_blk_arr[tsk->blk_idx_flg]; +else + blks = tsk->blks; + + buf_size = dif_blk_arr[tsk->blk_idx_flg]; + tsk->reftag =0xABBA ; + tsk->apptag =0xFACE ; + +for (i =0 ; i < blks; i++) { +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + (buf_size) * i), + buf_size,0 ); +else + dif_guardtag =dsa_calculate_crc_t10dif ((src1 + (buf_size +8 ) * i), + buf_size,0 ); + + dst_tag = dst1[buf_size +DIF_BLK_GRD_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_guardtag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_BLK_GRD_2 + (buf_size +8 ) * i]; + tmp_buf = dif_guardtag &0xff ; +if (tmp_buf != dst_tag) + g_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_APP_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_apptag) &0xff ; +if (tmp_buf != dst_tag) + a_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_1 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>24 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_2 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>16 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_3 + (buf_size +8 ) * i]; + tmp_buf = (dif_reftag >>8 ) &0xff ; +if (tmp_buf != dst_tag) + r_count++; + + dst_tag = dst1[buf_size +DIF_REF_TAG_4 + (buf_size +8 ) * i]; + tmp_buf = dif_reftag &0xff ; +if (tmp_buf != dst_tag) + r_count++; + +if (tsk->opcode !=DSA_OPCODE_DIF_UPDT ) + dif_reftag++; + } + +if (g_count || a_count || r_count) +err ("Tag Errors Found g: %ld a: %ld r: %ld\n" , g_count, a_count, r_count); +else +info ("All Tags Validated\n" , g_count, a_count, r_count); + +return DSA_STATUS_OK ; +} +int batch_result_verify (struct batch_task *btsk,int bof) {uint8_t core_stat, sub_stat;test/dsa.h +44
-0@@ -5,6 +5,7 @@#include <accfg/libaccel_config.h> #include <accfg/idxd.h> #include "accfg_test.h" +#include "crc16_t10_lookup.h" #define MAX_PATH_LENGTH 1024@@ -46,6 +47,19 @@#define BYPASS_CRC_INV_REF ((unsigned long)(1 << 17))#define BYPASS_DATA_REF ((unsigned long)(1 << 18)) +/* DIF index */ +#define DIF_BLK_GRD_1 0 +#define DIF_BLK_GRD_2 1 +#define DIF_APP_TAG_1 2 +#define DIF_APP_TAG_2 3 +#define DIF_REF_TAG_1 4 +#define DIF_REF_TAG_2 5 +#define DIF_REF_TAG_3 6 +#define DIF_REF_TAG_4 7 + +#define DIF_INVERT_CRC_SEED ((unsigned long)(1 << 2)) +#define DIF_INVERT_CRC_RESULT ((unsigned long)(1 << 3)) +#define ADDR_ALIGNMENT 32#define MIN_DELTA_RECORD_SIZE 80@@ -72,6 +86,11 @@ struct task {int test_flags;int crc_seed;unsigned long long *crc_seed_addr; +int reftag; +int apptag; +int guardtag; +unsigned long blks; +int blk_idx_flg; };struct task_node {@@ -247,6 +266,10 @@ int init_dualcast(struct task *tsk, int tflags, int opcode, unsigned long xfer_sint init_cr_delta (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_crcgen (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_copy_crc (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_dif_check (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_dif_ins (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_dif_strp (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_dif_updt (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);@@ -283,6 +306,12 @@ int dsa_wait_crcgen(struct dsa_context *ctx, struct task *tsk);int dsa_crc_copy_multi_task_nodes (struct dsa_context *ctx);int dsa_wait_crc_copy (struct dsa_context *ctx,struct task *tsk); +int dsa_dif_check_multi_task_nodes (struct dsa_context *ctx); +int dsa_dif_ins_multi_task_nodes (struct dsa_context *ctx); +int dsa_dif_strp_multi_task_nodes (struct dsa_context *ctx); +int dsa_dif_updt_multi_task_nodes (struct dsa_context *ctx); +int dsa_wait_dif (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_noop (struct task *tsk);void dsa_prep_drain (struct task *tsk);void dsa_prep_memcpy (struct task *tsk);@@ -303,6 +332,11 @@ void dsa_prep_crcgen(struct task *tsk);void dsa_reprep_crcgen (struct dsa_context *ctx,struct task *tsk);void dsa_prep_crc_copy (struct task *tsk);void dsa_reprep_crc_copy (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_dif_check (struct task *tsk); +void dsa_prep_dif_insert (struct task *tsk); +void dsa_prep_dif_strip (struct task *tsk); +void dsa_prep_dif_update (struct task *tsk); +void dsa_reprep_dif (struct dsa_context *ctx,struct task *tsk);int task_result_verify (struct task *tsk,int mismatch_expected);int task_result_verify_task_nodes (struct dsa_context *ctx,int mismatch_expected);@@ -314,6 +348,8 @@ int task_result_verify_dualcast(struct task *tsk, int mismatch_expected);int task_result_verify_ap_delta (struct task *tsk,int mismatch_expected);int task_result_verify_crcgen (struct task *tsk,int mismatch_expected);int task_result_verify_crc_copy (struct task *tsk,int mismatch_expected); +int task_result_verify_dif (struct task *tsk,unsigned long xfer_size,int mismatch_expected); +int task_result_verify_dif_tags (struct task *tsk,unsigned long xfer_size);int batch_result_verify (struct batch_task *btsk,int bof);int alloc_batch_task (struct dsa_context *ctx,unsigned int task_num,int num_itr);@@ -331,6 +367,10 @@ void dsa_prep_batch_cr_delta(struct batch_task *btsk);void dsa_prep_batch_ap_delta (struct batch_task *btsk);void dsa_prep_batch_crcgen (struct batch_task *btsk);void dsa_prep_batch_crc_copy (struct batch_task *btsk); +void dsa_prep_batch_dif_check (struct batch_task *btsk); +void dsa_prep_batch_dif_insert (struct batch_task *btsk); +void dsa_prep_batch_dif_strip (struct batch_task *btsk); +void dsa_prep_batch_dif_update (struct batch_task *btsk);int dsa_wait_batch (struct batch_task *btsk);void dsa_free (struct dsa_context *ctx);@@ -342,4 +382,8 @@ void free_batch_task(struct batch_task *btsk);void dsa_prep_desc_common (struct dsa_hw_desc *hw,char opcode,uint64_t dest,uint64_t src,size_t len,unsigned long dflags);void dsa_desc_submit (struct dsa_context *ctx,struct dsa_hw_desc *hw); + +uint16_t dsa_calculate_crc_t10dif (unsigned char *buffer,size_t len,int flags); +int get_dif_blksz_flg (unsigned long xfer_size); +unsigned long get_blks (unsigned long xfer_size);#endif test/dsa_test.c +104
-0@@ -111,6 +111,22 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,dsa_prep_batch_crc_copy (btsk_node->btsk);break ; +case DSA_OPCODE_DIF_CHECK : +dsa_prep_batch_dif_check (btsk_node->btsk); +break ; + +case DSA_OPCODE_DIF_INS : +dsa_prep_batch_dif_insert (btsk_node->btsk); +break ; + +case DSA_OPCODE_DIF_STRP : +dsa_prep_batch_dif_strip (btsk_node->btsk); +break ; + +case DSA_OPCODE_DIF_UPDT : +dsa_prep_batch_dif_update (btsk_node->btsk); +break ; +default :err ("Unsupported op %#x\n" , bopcode);return -EINVAL ;@@ -191,6 +207,85 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,return rc; } +static int test_dif (struct dsa_context *ctx,size_t buf_size, +int tflags,uint32_t opcode,int num_desc) +{ +struct task_node *tsk_node; +int rc =DSA_STATUS_OK ; +int itr = num_desc, i =0 , range =0 ; + +info ("testmemory: opcode %d len %#lx tflags %#x num_desc %ld\n" , + opcode, buf_size, tflags, num_desc); + + ctx->is_batch =0 ; + +if (ctx->dedicated ==ACCFG_WQ_SHARED ) + range = ctx->threshold; +else + range = ctx->wq_size -1 ; + +while (itr >0 && rc ==DSA_STATUS_OK ) { + i = (itr < range) ? itr : range; +/* Allocate memory to all the task nodes, desc, completion record*/ + rc =alloc_multiple_tasks (ctx, i); +if (rc !=DSA_STATUS_OK ) +return rc; + +/* allocate memory to src and dest buffers and fill in the desc for all the nodes*/ + tsk_node = ctx->multi_task_node; +while (tsk_node) { + tsk_node->tsk->xfer_size = buf_size; + tsk_node->tsk->blk_idx_flg =get_dif_blksz_flg (tsk_node->tsk->xfer_size); + + rc =init_task (tsk_node->tsk, tflags, opcode, buf_size); +if (rc !=DSA_STATUS_OK ) +return rc; + + tsk_node = tsk_node->next; + } + +switch (opcode) { +case DSA_OPCODE_DIF_CHECK : + rc =dsa_dif_check_multi_task_nodes (ctx); +if (rc !=DSA_STATUS_OK ) +return rc; +break ; + +case DSA_OPCODE_DIF_INS : + rc =dsa_dif_ins_multi_task_nodes (ctx); +if (rc !=DSA_STATUS_OK ) +return rc; +break ; + +case DSA_OPCODE_DIF_STRP : + rc =dsa_dif_strp_multi_task_nodes (ctx); +if (rc !=DSA_STATUS_OK ) +return rc; +break ; + +case DSA_OPCODE_DIF_UPDT : + rc =dsa_dif_updt_multi_task_nodes (ctx); +if (rc !=DSA_STATUS_OK ) +return rc; +break ; + +default : +err ("Unsupported op %#x\n" , opcode); +return -EINVAL ; + } + +/* Verification of all the nodes*/ + rc =task_result_verify_task_nodes (ctx,0 ); +if (rc !=DSA_STATUS_OK ) +return rc; + +dsa_free_task (ctx); + itr = itr - range; + } + +return rc; +} +static int test_noop (struct dsa_context *ctx,int tflags,int num_desc) {struct task_node *tsk_node;@@ -650,6 +745,15 @@ int main(int argc, char *argv[]) goto error;break ; +case DSA_OPCODE_DIF_CHECK : +case DSA_OPCODE_DIF_INS : +case DSA_OPCODE_DIF_STRP : +case DSA_OPCODE_DIF_UPDT : + rc =test_dif (dsa, buf_size, tflags, opcode, num_desc); +if (rc !=DSA_STATUS_OK ) + goto error; +break ; +default : rc = -EINVAL ;break ;test/prep.c +189
-0@@ -8,6 +8,8 @@#include <accfg/idxd.h> #include "dsa.h" +unsigned int dif_arr[] = {512 ,520 ,4096 ,4104 }; +void dsa_prep_desc_common (struct dsa_hw_desc *hw,char opcode,uint64_t dest,uint64_t src,size_t len,unsigned long dflags) {@@ -531,6 +533,193 @@ void dsa_prep_batch_crc_copy(struct batch_task *btsk) } } +void dsa_prep_dif_check (struct task *tsk) +{ +info ("preparing descriptor for dif check\n" ); + +dsa_prep_desc_common (tsk->desc, tsk->opcode, (uint64_t )(tsk->dst1), + (uint64_t )(tsk->src1), tsk->xfer_size, tsk->dflags); + tsk->desc->completion_addr = (uint64_t )(tsk->comp); + tsk->comp->status =0 ; + tsk->desc->chk_app_tag_seed = tsk->apptag; + tsk->desc->chk_ref_tag_seed = tsk->reftag; + tsk->desc->dif_chk_flags = tsk->blk_idx_flg; +} + +void dsa_prep_dif_insert (struct task *tsk) +{ +info ("preparing descriptor for dif insert\n" ); + +dsa_prep_desc_common (tsk->desc, tsk->opcode, (uint64_t )(tsk->dst1), + (uint64_t )(tsk->src1), tsk->xfer_size, tsk->dflags); + tsk->desc->completion_addr = (uint64_t )(tsk->comp); + tsk->comp->status =0 ; + tsk->desc->ins_app_tag_seed = tsk->apptag; + tsk->desc->ins_ref_tag_seed = tsk->reftag; + tsk->desc->dif_ins_flags = tsk->blk_idx_flg; +} + +void dsa_prep_dif_strip (struct task *tsk) +{ +info ("preparing descriptor for dif strip\n" ); + +dsa_prep_desc_common (tsk->desc, tsk->opcode, (uint64_t )(tsk->dst1), + (uint64_t )(tsk->src1), tsk->xfer_size, tsk->dflags); + tsk->desc->completion_addr = (uint64_t )(tsk->comp); + tsk->comp->status =0 ; + tsk->desc->chk_app_tag_seed = tsk->apptag; + tsk->desc->chk_ref_tag_seed = tsk->reftag; + tsk->desc->dif_chk_flags = tsk->blk_idx_flg; +} + +void dsa_prep_dif_update (struct task *tsk) +{ +info ("preparing descriptor for dif update\n" ); + +dsa_prep_desc_common (tsk->desc, tsk->opcode, (uint64_t )(tsk->dst1), + (uint64_t )(tsk->src1), tsk->xfer_size, tsk->dflags); + tsk->desc->completion_addr = (uint64_t )(tsk->comp); + tsk->comp->status =0 ; + tsk->desc->src_app_tag_seed = tsk->apptag; + tsk->desc->src_ref_tag_seed = tsk->reftag; + tsk->desc->dest_ref_tag_seed = tsk->reftag; + tsk->desc->dest_app_tag_seed = tsk->apptag; + tsk->desc->src_upd_flags =0x80 ; + tsk->desc->upd_dest_flags =0x80 ; + tsk->desc->dif_upd_flags = tsk->blk_idx_flg; +} + +void dsa_reprep_dif (struct dsa_context *ctx,struct task *tsk) +{ +struct dsa_completion_record *compl = tsk->comp; +struct dsa_hw_desc *hw = tsk->desc; +unsigned long blks_completed =0 ; + +info ("PF addr %#lx dir %d bc %#x\n" , + compl->fault_addr, compl->result, + compl->bytes_completed); + + hw->src_addr += compl->bytes_completed; + hw->ins_ref_tag_seed = compl->dif_ins_ref_tag; +if (tsk->opcode ==DSA_OPCODE_DIF_INS ) { + blks_completed = compl->bytes_completed / (dif_arr[tsk->blk_idx_flg]); + hw->xfer_size -= compl->bytes_completed; + hw->dst_addr += compl->bytes_completed +8 * blks_completed; + hw->ins_app_tag_seed = compl->dif_ins_app_tag; + hw->ins_ref_tag_seed = compl->dif_ins_ref_tag; + } + +if (tsk->opcode ==DSA_OPCODE_DIF_STRP ) { + blks_completed = compl->bytes_completed / (dif_arr[tsk->blk_idx_flg] +8 ); + hw->xfer_size -= compl->bytes_completed; + hw->dst_addr += dif_arr[tsk->blk_idx_flg] * blks_completed; + hw->chk_app_tag_seed = compl->dif_chk_app_tag; + hw->chk_ref_tag_seed = compl->dif_chk_ref_tag; + } + +if (tsk->opcode ==DSA_OPCODE_DIF_UPDT ) { + blks_completed = compl->bytes_completed / (dif_arr[tsk->blk_idx_flg] +8 ); + hw->xfer_size -= compl->bytes_completed; + hw->dst_addr += (dif_arr[tsk->blk_idx_flg] +8 ) * blks_completed; + hw->src_app_tag_seed = compl->dif_upd_src_app_tag; + hw->dest_app_tag_seed = compl->dif_upd_dest_app_tag; + hw->src_ref_tag_seed = compl->dif_upd_dest_ref_tag; + hw->dest_ref_tag_seed = compl->dif_upd_dest_ref_tag; + } +if (tsk->opcode ==DSA_OPCODE_DIF_CHECK ) { + blks_completed = compl->bytes_completed / (dif_arr[tsk->blk_idx_flg] +8 ); + hw->xfer_size -= compl->bytes_completed; + hw->chk_app_tag_seed = compl->dif_chk_app_tag; + hw->chk_ref_tag_seed = compl->dif_chk_ref_tag; + } + +resolve_page_fault (compl->fault_addr, compl->status); + + compl->status =0 ; + +dsa_desc_submit (ctx, hw); +} + +void dsa_prep_batch_dif_check (struct batch_task *btsk) +{ +int i; +struct task *sub_task; + +for (i =0 ; i < btsk->task_num; i++) { + sub_task = &btsk->sub_tasks[i]; + sub_task->xfer_size = btsk->sub_tasks[i].xfer_size; + sub_task->desc->dif_chk_flags = btsk->sub_tasks[i].blk_idx_flg; +dsa_prep_desc_common (sub_task->desc, sub_task->opcode, + (uint64_t )(sub_task->dst1), (uint64_t )(sub_task->src1), + sub_task->xfer_size, sub_task->dflags); + sub_task->desc->completion_addr = (uint64_t )(sub_task->comp); + sub_task->comp->status =0 ; + sub_task->desc->chk_app_tag_seed = sub_task->apptag; + sub_task->desc->chk_ref_tag_seed = sub_task->reftag; + } +} + +void dsa_prep_batch_dif_insert (struct batch_task *btsk) +{ +int i; +struct task *sub_task; + +for (i =0 ; i < btsk->task_num; i++) { + sub_task = &btsk->sub_tasks[i]; + sub_task->xfer_size = btsk->sub_tasks[i].xfer_size; + sub_task->desc->dif_chk_flags = btsk->sub_tasks[i].blk_idx_flg; +dsa_prep_desc_common (sub_task->desc, sub_task->opcode, + (uint64_t )(sub_task->dst1), (uint64_t )(sub_task->src1), + sub_task->xfer_size, sub_task->dflags); + sub_task->desc->completion_addr = (uint64_t )(sub_task->comp); + sub_task->comp->status =0 ; + sub_task->desc->ins_app_tag_seed = sub_task->apptag; + sub_task->desc->ins_ref_tag_seed = sub_task->reftag; + } +} + +void dsa_prep_batch_dif_strip (struct batch_task *btsk) +{ +int i; +struct task *sub_task; + +for (i =0 ; i < btsk->task_num; i++) { + sub_task = &btsk->sub_tasks[i]; + sub_task->xfer_size = btsk->sub_tasks[i].xfer_size; + sub_task->desc->dif_chk_flags = btsk->sub_tasks[i].blk_idx_flg; +dsa_prep_desc_common (sub_task->desc, sub_task->opcode, + (uint64_t )(sub_task->dst1), (uint64_t )(sub_task->src1), + sub_task->xfer_size, sub_task->dflags); + sub_task->desc->completion_addr = (uint64_t )(sub_task->comp); + sub_task->comp->status =0 ; + sub_task->desc->chk_app_tag_seed = sub_task->apptag; + sub_task->desc->chk_ref_tag_seed = sub_task->reftag; + } +} + +void dsa_prep_batch_dif_update (struct batch_task *btsk) +{ +int i; +struct task *sub_task; + +for (i =0 ; i < btsk->task_num; i++) { + sub_task = &btsk->sub_tasks[i]; + sub_task->xfer_size = btsk->sub_tasks[i].xfer_size; + sub_task->desc->dif_chk_flags = btsk->sub_tasks[i].blk_idx_flg; +dsa_prep_desc_common (sub_task->desc, sub_task->opcode, + (uint64_t )(sub_task->dst1), (uint64_t )(sub_task->src1), + sub_task->xfer_size, sub_task->dflags); + sub_task->desc->completion_addr = (uint64_t )(sub_task->comp); + sub_task->comp->status =0 ; + sub_task->desc->src_app_tag_seed = sub_task->apptag; + sub_task->desc->src_ref_tag_seed = sub_task->reftag; + sub_task->desc->dest_ref_tag_seed = sub_task->reftag; + sub_task->desc->dest_app_tag_seed = sub_task->apptag; + sub_task->desc->src_upd_flags =0x80 ; + sub_task->desc->upd_dest_flags =0x80 ; + } +} +void dsa_prep_batch (struct batch_task *btsk,unsigned long desc_flags) {struct task *ctsk = btsk->core_task;
Tony Zhu
PATCH v3 7/7 accel-config/test: add cache flush operation support
In reply to Tony ZhuThe Cache Flush operation flushes the processor caches at the Destination Address.
--- test/dsa.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ test/dsa.h | 7 +++++ test/dsa_test.c | 10 +++++++ test/prep.c | 46 +++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+)
test/dsa.c +77 -0
@@ -696,6 +696,23 @@ int init_dif_updt(struct task *tsk, int tflags, int opcode, unsigned long xfer_sreturn DSA_STATUS_OK ; } +int init_cflush (struct task *tsk,int tflags,int opcode,unsigned long xfer_size) +{ +unsigned long force_align =ADDR_ALIGNMENT ; + + tsk->pattern =0x0123456789abcdef ; + tsk->opcode = opcode; + tsk->test_flags = tflags; + tsk->xfer_size = xfer_size; + + tsk->dst1 =aligned_alloc (force_align, xfer_size); +if (!tsk->dst1) +return -ENOMEM ; +memset_pattern (tsk->dst1, tsk->pattern, xfer_size); + +return DSA_STATUS_OK ; +} +/* this function is re-used by batch task */ int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size)
@@ -755,6 +772,10 @@ int init_task(struct task *tsk, int tflags, int opcode,case DSA_OPCODE_DIF_UPDT : rc =init_dif_updt (tsk, tflags, opcode, xfer_size);break ; + +case DSA_OPCODE_CFLUSH : + rc =init_cflush (tsk, tflags, opcode, xfer_size); +break ; }if (rc !=DSA_STATUS_OK ) {
@@ -1828,6 +1849,62 @@ int dsa_dif_updt_multi_task_nodes(struct dsa_context *ctx)return ret; } +int dsa_wait_cflush (struct dsa_context *ctx,struct task *tsk) +{ +struct dsa_hw_desc *desc = tsk->desc; +struct dsa_completion_record *comp = tsk->comp; + +int rc; + +again: + rc =dsa_wait_on_desc_timeout (comp, ms_timeout); +if (rc <0 ) { +err ("cflush desc timeout\n" ); +return DSA_STATUS_TIMEOUT ; + } + +/* re-submit if PAGE_FAULT reported by HW && BOF is off */ +if (stat_val (comp->status) ==DSA_COMP_PAGE_FAULT_NOBOF && + !(desc->flags &IDXD_OP_FLAG_BOF )) { +dsa_reprep_cflush (ctx, tsk); + goto again; + } + +return DSA_STATUS_OK ; +} + +int dsa_cflush_multi_task_nodes (struct dsa_context *ctx) +{ +struct task_node *tsk_node = ctx->multi_task_node; +int ret =DSA_STATUS_OK ; + +while (tsk_node) { + tsk_node->tsk->dflags =IDXD_OP_FLAG_CRAV |IDXD_OP_FLAG_RCR ; +if ((tsk_node->tsk->test_flags &TEST_FLAGS_BOF ) && ctx->bof) + tsk_node->tsk->dflags |=IDXD_OP_FLAG_BOF ; + +dsa_prep_cflush (tsk_node->tsk); + tsk_node = tsk_node->next; + } + + tsk_node = ctx->multi_task_node; +while (tsk_node) { +dsa_desc_submit (ctx, tsk_node->tsk->desc); + tsk_node = tsk_node->next; + } + tsk_node = ctx->multi_task_node; +info ("Submitted all cflush jobs\n" ); + +while (tsk_node) { + ret =dsa_wait_cflush (ctx, tsk_node->tsk); +if (ret !=DSA_STATUS_OK ) +info ("Desc: %p failed with ret: %d\n" , + tsk_node->tsk->desc, tsk_node->tsk->comp->status); + tsk_node = tsk_node->next; + } +return ret; +} +/* mismatch_expected: expect mismatched buffer with success status 0x1 */ int task_result_verify (struct task *tsk,int mismatch_expected) {
test/dsa.h +7 -0
@@ -270,6 +270,7 @@ int init_dif_check(struct task *tsk, int tflags, int opcode, unsigned long xfer_int init_dif_ins (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_dif_strp (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_dif_updt (struct task *tsk,int tflags,int opcode,unsigned long xfer_size); +int init_cflush (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);int init_task (struct task *tsk,int tflags,int opcode,unsigned long xfer_size);
@@ -312,6 +313,9 @@ int dsa_dif_strp_multi_task_nodes(struct dsa_context *ctx);int dsa_dif_updt_multi_task_nodes (struct dsa_context *ctx);int dsa_wait_dif (struct dsa_context *ctx,struct task *tsk); +int dsa_cflush_multi_task_nodes (struct dsa_context *ctx); +int dsa_wait_cflush (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_noop (struct task *tsk);void dsa_prep_drain (struct task *tsk);void dsa_prep_memcpy (struct task *tsk);
@@ -337,6 +341,8 @@ void dsa_prep_dif_insert(struct task *tsk);void dsa_prep_dif_strip (struct task *tsk);void dsa_prep_dif_update (struct task *tsk);void dsa_reprep_dif (struct dsa_context *ctx,struct task *tsk); +void dsa_prep_cflush (struct task *tsk); +void dsa_reprep_cflush (struct dsa_context *ctx,struct task *tsk);int task_result_verify (struct task *tsk,int mismatch_expected);int task_result_verify_task_nodes (struct dsa_context *ctx,int mismatch_expected);
@@ -371,6 +377,7 @@ void dsa_prep_batch_dif_check(struct batch_task *btsk);void dsa_prep_batch_dif_insert (struct batch_task *btsk);void dsa_prep_batch_dif_strip (struct batch_task *btsk);void dsa_prep_batch_dif_update (struct batch_task *btsk); +void dsa_prep_batch_cflush (struct batch_task *btsk);int dsa_wait_batch (struct batch_task *btsk);void dsa_free (struct dsa_context *ctx);
test/dsa_test.c +10 -0
@@ -127,6 +127,10 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,dsa_prep_batch_dif_update (btsk_node->btsk);break ; +case DSA_OPCODE_CFLUSH : +dsa_prep_batch_cflush (btsk_node->btsk); +break ; +default :err ("Unsupported op %#x\n" , bopcode);return -EINVAL ;
@@ -478,6 +482,11 @@ static int test_memory(struct dsa_context *ctx, size_t buf_size,if (rc !=DSA_STATUS_OK )return rc;break ; +case DSA_OPCODE_CFLUSH : + rc =dsa_cflush_multi_task_nodes (ctx); +if (rc !=DSA_STATUS_OK ) +return rc; +break ;default :err ("Unsupported op %#x\n" , opcode);return -EINVAL ;
@@ -726,6 +735,7 @@ int main(int argc, char *argv[])case DSA_OPCODE_COMPARE :case DSA_OPCODE_COMPVAL :case DSA_OPCODE_DUALCAST : +case DSA_OPCODE_CFLUSH : rc =test_memory (dsa, buf_size, tflags, opcode, num_desc);if (rc !=DSA_STATUS_OK ) goto error;
test/prep.c +46 -0
52 lines not on this page · raw message
Signature · 1 line
2.27.0