Skip to contentSkip to conversation

Add opcode operation support in spec

PATCH Superseded Tony Zhu 2 participants 14 messages Feb 11, 2022

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Tony Zhu

author
#0 lore raw

cover Add opcode operation support in spec

Only has memory opocde operation support, add other opcode code support to cover all.

Tony Zhu (9):
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 pattern2 to fill destination buffers accel-config/test: rewrite init task and add the init of dif
operations
accel-config/test: add CRC Generation and Copy with CRC Generation
support
accel-config/test: add create and apply delta record result
verification
accel-config/test: add 4 dif operations support accel-config/test: split drain multi task from noop multi task accel-config/test: add cache flush operation support

 test/crc16_t10_lookup.h |   36 ++
 test/dsa.c              | 1349 +++++++++++++++++++++++++++++++++++++--
 test/dsa.h              |   91 +++
 test/dsa_crc32.h        |  351 ++++++++++
 test/dsa_test.c         |  345 +++++++++-
 test/prep.c             |  442 +++++++++++++
 6 files changed, 2544 insertions(+), 70 deletions(-)
 create mode 100644 test/crc16_t10_lookup.h
 create mode 100644 test/dsa_crc32.h
Signature · 1 line
2.27.0
author
#1 lore raw

PATCH 1/9 accel-config/test: add drain operation support for single submission

Drain submission is similiar as noop operation, so modify test_noop to support drain operation. It is not necessary to test drain in batch, single submission is enough.A Drain descriptor may not be included in a batch. It is treated as an unsupported operation type. The batch completion status is 0x5,the drain subtask completion status should be 0x10. In dsa_test for batch, drain is not a support operation.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa_test.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
test/dsa_test.c +4 -3
index eccf89c..8407bfc 100644
@@ -136,7 +136,7 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,
 	return rc;
 }
 
-static int test_noop(struct dsa_context *ctx, int tflags, int num_desc)
+static int test_noop_drain(struct dsa_context *ctx, int tflags, uint32_t opcode, int num_desc)
 {
 	struct task_node *tsk_node;
 	int rc = DSA_STATUS_OK;
@@ -161,7 +161,7 @@ static int test_noop(struct dsa_context *ctx, int tflags, int num_desc)
 		/* 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->opcode = DSA_OPCODE_NOOP;
+			tsk_node->tsk->opcode = opcode;
 			tsk_node->tsk->test_flags = tflags;
 			tsk_node = tsk_node->next;
 		}
@@ -404,7 +404,8 @@ int main(int argc, char *argv[])
 
 	switch (opcode) {
 	case DSA_OPCODE_NOOP:
-		rc = test_noop(dsa, tflags, num_desc);
+	case DSA_OPCODE_DRAIN:
+		rc = test_noop_drain(dsa, tflags, opcode,  num_desc);
 		if (rc != DSA_STATUS_OK)
 			goto error;
 		break;
Signature · 1 line
2.27.0
#2 lore raw

[Accel-config] Re: [PATCH v1 1/9] accel-config/test: add drain operation support for single submission

Quoted 6 lines · Tony Zhu

Drain submission is similiar as noop operation, so modify test_noop to support drain operation. It is not necessary to test drain in batch, single submission is enough.A Drain descriptor may not be included in a batch. It is treated as an unsupported operation type. The batch completion status is 0x5,the drain subtask completion status should be 0x10. In dsa_test for batch, drain is not a support operation.

For drain operation, it would make more sense if another operation is submitted in front of it. Perhaps send a MEMMOVE immediately followed by DRAIN?

Quoted 38 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
  test/dsa_test.c | 7 ++++---
  1 file changed, 4 insertions(+), 3 deletions(-)
test/dsa_test.c +4 -3
index eccf89c..8407bfc 100644
@@ -136,7 +136,7 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,
  	return rc;
  }
 
-static int test_noop(struct dsa_context *ctx, int tflags, int num_desc)
+static int test_noop_drain(struct dsa_context *ctx, int tflags, uint32_t opcode, int num_desc)
  {
  	struct task_node *tsk_node;
  	int rc = DSA_STATUS_OK;
@@ -161,7 +161,7 @@ static int test_noop(struct dsa_context *ctx, int tflags, int num_desc)
  		/* 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->opcode = DSA_OPCODE_NOOP;
+			tsk_node->tsk->opcode = opcode;
  			tsk_node->tsk->test_flags = tflags;
  			tsk_node = tsk_node->next;
  		}
@@ -404,7 +404,8 @@ int main(int argc, char *argv[])
 
  	switch (opcode) {
  	case DSA_OPCODE_NOOP:
-		rc = test_noop(dsa, tflags, num_desc);
+	case DSA_OPCODE_DRAIN:
+		rc = test_noop_drain(dsa, tflags, opcode,  num_desc);
  		if (rc != DSA_STATUS_OK)
  			goto error;
  		break;
author
#3 lore raw

PATCH 2/9 accel-config/test: add create and apply delta record operation support

In reply to Tony Zhu

Add DSA_OPCODE_CR_DELTA(0x8) and DSA_OPCODE_AP_DELTA(0x8) opcodes support.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c      | 112 ++++++++++++++++++++++++++++++++++++++++++
 test/dsa.h      |  14 ++++++
 test/dsa_test.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++-
 test/prep.c     | 116 ++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 367 insertions(+), 1 deletion(-)
test/dsa.c +112 -0
index 29aee41..7d5b396 100644
@@ -981,6 +981,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 memcpy 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 memcpy 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)
 {
test/dsa.h +14 -0
index 382fc66..0af226c 100644
@@ -41,6 +41,7 @@
 #define DSA_COMP_STAT_CODE_MASK                 0x3F
 #define DSA_COMP_STAT_RW_MASK                   0x80
 
+#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)
 
@@ -56,6 +57,7 @@ struct task {
 	void *src2;
 	void *dst1;
 	void *dst2;
+	void *delta1;
 	uint64_t pattern;
 	uint64_t xfer_size;
 	uint32_t dflags;
@@ -248,6 +250,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_memcpy(struct task *tsk);
 void dsa_reprep_memcpy(struct dsa_context *ctx, struct task *tsk);
@@ -259,6 +267,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);
@@ -280,6 +292,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

128 lines not on this page · raw message

Signature · 1 line
2.27.0
author
#4 lore raw

PATCH 3/9 accel-config/test: add pattern2 to fill destination buffers

In reply to Tony Zhu

Use pattern to fill source buffers, use pattern2 to fill destination buffers.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c | 7 +++----
 test/dsa.h | 1 +
 2 files changed, 4 insertions(+), 4 deletions(-)
test/dsa.c +3 -4
index 7d5b396..f427664 100644
@@ -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
index 0af226c..6363bbd 100644
@@ -59,6 +59,7 @@ struct task {
 	void *dst2;
 	void *delta1;
 	uint64_t pattern;
+	uint64_t pattern2;
 	uint64_t xfer_size;
 	uint32_t dflags;
 	int test_flags;
Signature · 1 line
2.27.0
#5 lore raw

[Accel-config] Re: [PATCH v1 3/9] accel-config/test: add pattern2 to fill destination buffers

Quoted 2 lines · Tony Zhu

Use pattern to fill source buffers, use pattern2 to fill destination buffers.

Just a question. What is pattern 2 used for? Checking to see if it gets overwritten?

Quoted 51 lines
Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
  test/dsa.c | 7 +++----
  test/dsa.h | 1 +
  2 files changed, 4 insertions(+), 4 deletions(-)
test/dsa.c +3 -4
index 7d5b396..f427664 100644
@@ -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
index 0af226c..6363bbd 100644
@@ -59,6 +59,7 @@ struct task {
  	void *dst2;
  	void *delta1;
  	uint64_t pattern;
+	uint64_t pattern2;
  	uint64_t xfer_size;
  	uint32_t dflags;
  	int test_flags;
author
#6 lore raw

PATCH 4/9 accel-config/test: rewrite init task and add the init of dif operations

In reply to Tony Zhu

DIF computation is performed on each block of source data, to avoid mistakes the task init will be completed one by one.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++----
 test/dsa.h |  34 ++++++
 2 files changed, 313 insertions(+), 20 deletions(-)
test/dsa.c +279 -20
index f427664..0743895 100644
@@ -22,6 +22,37 @@ unsigned int ms_timeout = 5000;
 int debug_logging;
 static int umwait_support;
 
+unsigned int dif_blk_arr[] = {512, 520, 4096, 4104};
+
+/*ANINDYA Logic to get blk_sz_flg*/
+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;
+}
+
+/* ASD Logic */
+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)
 {
@@ -284,7 +315,22 @@ struct task *__alloc_task(void)
 int init_task(struct task *tsk, int tflags, int opcode,
 	      unsigned long xfer_size)
 {
-	dbg("initilizing single task %#lx\n", tsk);
+	unsigned long buf_size;
+	unsigned long force_align = ADDR_ALIGNMENT;
+	uint8_t *src;
+	uint8_t *src2;
+	uint8_t *src3;
+	unsigned int dif_reftag;
+	unsigned int dif_apptag;
+	unsigned int dif_guardtag;
+	unsigned long delta_size;
+	unsigned long blks = 0;
+	unsigned long i;
+	uint64_t patternx = 0x1234;
+	uint64_t patterny = 0x1233;
+	unsigned long dif_size;
+
+	dbg("initilizing task %#lx\n", tsk);
 
 	tsk->pattern = 0x0123456789abcdef;
 	tsk->pattern2 = 0xfedcba9876543210;
@@ -292,47 +338,241 @@ int init_task(struct task *tsk, int tflags, int opcode,
 	tsk->test_flags = tflags;
 	tsk->xfer_size = xfer_size;
 
+	tsk->apptag = 0xFACE;
+	tsk->reftag = 0xABBA;
+
 	/* 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);
+		tsk->src1 = aligned_alloc(force_align, xfer_size);
 		if (!tsk->src1)
 			return -ENOMEM;
 		memset_pattern(tsk->src1, tsk->pattern, xfer_size);
-	}
 
-	/* allocate memory: src2*/
-	switch (opcode) {
+		tsk->dst1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->dst1)
+			return -ENOMEM;
+		memset_pattern(tsk->dst1, tsk->pattern2, xfer_size);
+		break;
+
+	case DSA_OPCODE_MEMFILL:
+		tsk->dst1 = aligned_alloc(1 << 12, xfer_size);
+		if (!tsk->dst1)
+			return -ENOMEM;
+		memset(tsk->dst1, 0, xfer_size);
+		break;
+
 	case DSA_OPCODE_COMPARE:
-		tsk->src2 = malloc(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);
-	}
+		break;
+
+	case DSA_OPCODE_COMPVAL:
+		tsk->src1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->src1)
+			return -ENOMEM;
+		memset_pattern(tsk->src1, tsk->pattern, xfer_size);
+		break;
+
+	case DSA_OPCODE_CFLUSH:
+		tsk->dst1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->dst1)
+			return -ENOMEM;
+		memset_pattern(tsk->dst1, tsk->pattern, 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->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);
-	}
 
-	/* 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);
+		break;
+
+	case DSA_OPCODE_DIF_CHECK:	/*DIF_CHECK_OPCODE*/
+		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 = (uint8_t *)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++;
+		}
+		break;
+
+	case DSA_OPCODE_DIF_INS:
+		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;
+		break;
+
+	case DSA_OPCODE_DIF_STRP:
+		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;
+
+		src2 = (uint8_t *)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((src2 + dif_size), tsk->pattern, buf_size);
+			dif_guardtag = dsa_calculate_crc_t10dif((src2 + dif_size), buf_size, 0);
+			src2[buf_size + DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >> 8) & 0xFF;
+			src2[buf_size + DIF_BLK_GRD_2 + dif_size] = dif_guardtag & 0xFF;
+			src2[buf_size + DIF_APP_TAG_1 + dif_size] = (dif_apptag >> 8) & 0xFF;
+			src2[buf_size + DIF_APP_TAG_2 + dif_size] = (dif_apptag) & 0xFF;
+			src2[buf_size + DIF_REF_TAG_1 + dif_size] = (dif_reftag >> 24) & 0xFF;
+			src2[buf_size + DIF_REF_TAG_2 + dif_size] = (dif_reftag >> 16) & 0xFF;
+			src2[buf_size + DIF_REF_TAG_3 + dif_size] = (dif_reftag >> 8) & 0xFF;
+			src2[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;
+		break;
+
+	case DSA_OPCODE_DIF_UPDT:
+		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;
+
+		src3 = (uint8_t *)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((src3 + dif_size), tsk->pattern, buf_size);
+			dif_guardtag = dsa_calculate_crc_t10dif((src3 + dif_size), buf_size, 0);
+			src3[buf_size + DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >> 8) & 0xFF;
+			src3[buf_size + DIF_BLK_GRD_2 + dif_size] = dif_guardtag & 0xFF;
+			src3[buf_size + DIF_APP_TAG_1 + dif_size] = (dif_apptag >> 8) & 0xFF;
+			src3[buf_size + DIF_APP_TAG_2 + dif_size] = (dif_apptag) & 0xFF;
+			src3[buf_size + DIF_REF_TAG_1 + dif_size] = (dif_reftag >> 24) & 0xFF;
+			src3[buf_size + DIF_REF_TAG_2 + dif_size] = (dif_reftag >> 16) & 0xFF;
+			src3[buf_size + DIF_REF_TAG_3 + dif_size] = (dif_reftag >> 8) & 0xFF;
+			src3[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;
+		break;
+
+	case DSA_OPCODE_AP_DELTA:
+	case DSA_OPCODE_CR_DELTA:
+		tsk->src1 = aligned_alloc(force_align, tsk->xfer_size);
+		if (!tsk->src1)
+			return -ENOMEM;
+		memset_pattern(tsk->src1, patternx, tsk->xfer_size);
+		tsk->src2 = aligned_alloc(force_align, tsk->xfer_size);
+		if (!tsk->src2)
+			return -ENOMEM;
+		memset_pattern(tsk->src2, patterny, 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;
+		}
+		break;
+
+	case DSA_OPCODE_CRCGEN:
+		tsk->src1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->src1)
+			return -ENOMEM;
+		memset_pattern(tsk->src1, tsk->pattern, xfer_size);
+		srand(time(0));
+		tsk->crc_seed = 0x12345678;
+		if (tsk->test_flags & (unsigned int)(READ_CRC_SEED)) {
+			tsk->crc_seed_addr = aligned_alloc(ADDR_ALIGNMENT, sizeof(tsk->crc_seed));
+			*tsk->crc_seed_addr = tsk->crc_seed;
+			tsk->crc_seed = 0x0;
+		}
+		break;
+
+	case DSA_OPCODE_COPY_CRC:
+		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);
+		srand(time(0));
+		tsk->crc_seed = 0x12345678;
+		if (tsk->test_flags & (unsigned int)(READ_CRC_SEED)) {
+			tsk->crc_seed_addr = aligned_alloc(ADDR_ALIGNMENT, sizeof(tsk->crc_seed));
+			*tsk->crc_seed_addr = tsk->crc_seed;
+			tsk->crc_seed = 0x0;
+		}
+		break;
 	}
 
 	dbg("Mem allocated: s1 %#lx s2 %#lx d1 %#lx d2 %#lx\n",
@@ -1237,6 +1477,25 @@ int task_result_verify_dualcast(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)
+{
+	uint16_t 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;
+}
+
 int batch_result_verify(struct batch_task *btsk, int bof)
 {
 	uint8_t core_stat, sub_stat;
test/dsa.h +34 -0
index 6363bbd..72c2675 100644
@@ -4,6 +4,7 @@
 #define __TEST_DSA_H__
 #include <accfg/libaccel_config.h>
 #include <accfg/idxd.h>
+#include "crc16_t10_lookup.h"
 #include "accfg_test.h"
 
 #define MAX_PATH_LENGTH 1024
@@ -41,6 +42,26 @@
 #define DSA_COMP_STAT_CODE_MASK                 0x3F
 #define DSA_COMP_STAT_RW_MASK                   0x80
 
+#define DIF_INVERT_CRC_SEED         ((unsigned long)(1 << 2))
+#define DIF_INVERT_CRC_RESULT       ((unsigned long)(1 << 3))
+
+/* 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
+
+/* 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
 /* helper macro to get lower 6 bits (ret code) from completion status */
 #define stat_val(status) ((status) & DSA_COMP_STAT_CODE_MASK)
@@ -63,6 +84,14 @@ struct task {
 	uint64_t xfer_size;
 	uint32_t dflags;
 	int test_flags;
+	int reftag;
+	int apptag;
+	int guardtag;
+	unsigned long blks;
+	int blk_idx_flg;
+	int crc_seed;
+	int delta_rec_size;
+	uint64_t *crc_seed_addr;
 };
 
 struct task_node {
@@ -306,4 +335,9 @@ 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
Signature · 1 line
2.27.0
#7 lore raw

[Accel-config] Re: [PATCH v1 4/9] accel-config/test: rewrite init task and add the init of dif operations

On 2/11/2022 6:16 AM, Tony Zhu wrote:

Can you break apart the rewrite and the adding of dif operations? Also the init task is getting rather large. Can you break each up into sub-functions?

Quoted 14 lines

DIF computation is performed on each block of source data, to avoid mistakes the task init will be completed one by one.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
  test/dsa.c | 299 +++++++++++++++++++++++++++++++++++++++++++++++++----
  test/dsa.h |  34 ++++++
  2 files changed, 313 insertions(+), 20 deletions(-)
test/dsa.c +0 -0
index f427664..0743895 100644

test/dsa.c unsigned int ms_timeout = 5000; · line 27

Quoted 6 lines
test/dsa.c +3 -0
@@ -22,6 +22,37 @@ unsigned int ms_timeout = 5000;
  int debug_logging;
  static int umwait_support;
 
+unsigned int dif_blk_arr[] = {512, 520, 4096, 4104};
+
+/*ANINDYA Logic to get blk_sz_flg*/

What is ANINDYA? Need more explanation

test/dsa.c unsigned int ms_timeout = 5000; · line 40

Quoted 13 lines
test/dsa.c +13 -0
+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;
+}
+
+/* ASD Logic */

What is ASD?

Quoted 393 lines
test/dsa.c +263 -20
+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)
  {
@@ -284,7 +315,22 @@ struct task *__alloc_task(void)
  int init_task(struct task *tsk, int tflags, int opcode,
  	      unsigned long xfer_size)
  {
-	dbg("initilizing single task %#lx\n", tsk);
+	unsigned long buf_size;
+	unsigned long force_align = ADDR_ALIGNMENT;
+	uint8_t *src;
+	uint8_t *src2;
+	uint8_t *src3;
+	unsigned int dif_reftag;
+	unsigned int dif_apptag;
+	unsigned int dif_guardtag;
+	unsigned long delta_size;
+	unsigned long blks = 0;
+	unsigned long i;
+	uint64_t patternx = 0x1234;
+	uint64_t patterny = 0x1233;
+	unsigned long dif_size;
+
+	dbg("initilizing task %#lx\n", tsk);
 
  	tsk->pattern = 0x0123456789abcdef;
  	tsk->pattern2 = 0xfedcba9876543210;
@@ -292,47 +338,241 @@ int init_task(struct task *tsk, int tflags, int opcode,
  	tsk->test_flags = tflags;
  	tsk->xfer_size = xfer_size;
 
+	tsk->apptag = 0xFACE;
+	tsk->reftag = 0xABBA;
+
  	/* 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);
+		tsk->src1 = aligned_alloc(force_align, xfer_size);
  		if (!tsk->src1)
  			return -ENOMEM;
  		memset_pattern(tsk->src1, tsk->pattern, xfer_size);
-	}
 
-	/* allocate memory: src2*/
-	switch (opcode) {
+		tsk->dst1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->dst1)
+			return -ENOMEM;
+		memset_pattern(tsk->dst1, tsk->pattern2, xfer_size);
+		break;
+
+	case DSA_OPCODE_MEMFILL:
+		tsk->dst1 = aligned_alloc(1 << 12, xfer_size);
+		if (!tsk->dst1)
+			return -ENOMEM;
+		memset(tsk->dst1, 0, xfer_size);
+		break;
+
  	case DSA_OPCODE_COMPARE:
-		tsk->src2 = malloc(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);
-	}
+		break;
+
+	case DSA_OPCODE_COMPVAL:
+		tsk->src1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->src1)
+			return -ENOMEM;
+		memset_pattern(tsk->src1, tsk->pattern, xfer_size);
+		break;
+
+	case DSA_OPCODE_CFLUSH:
+		tsk->dst1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->dst1)
+			return -ENOMEM;
+		memset_pattern(tsk->dst1, tsk->pattern, 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->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);
-	}
 
-	/* 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);
+		break;
+
+	case DSA_OPCODE_DIF_CHECK:	/*DIF_CHECK_OPCODE*/
+		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 = (uint8_t *)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++;
+		}
+		break;
+
+	case DSA_OPCODE_DIF_INS:
+		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;
+		break;
+
+	case DSA_OPCODE_DIF_STRP:
+		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;
+
+		src2 = (uint8_t *)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((src2 + dif_size), tsk->pattern, buf_size);
+			dif_guardtag = dsa_calculate_crc_t10dif((src2 + dif_size), buf_size, 0);
+			src2[buf_size + DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >> 8) & 0xFF;
+			src2[buf_size + DIF_BLK_GRD_2 + dif_size] = dif_guardtag & 0xFF;
+			src2[buf_size + DIF_APP_TAG_1 + dif_size] = (dif_apptag >> 8) & 0xFF;
+			src2[buf_size + DIF_APP_TAG_2 + dif_size] = (dif_apptag) & 0xFF;
+			src2[buf_size + DIF_REF_TAG_1 + dif_size] = (dif_reftag >> 24) & 0xFF;
+			src2[buf_size + DIF_REF_TAG_2 + dif_size] = (dif_reftag >> 16) & 0xFF;
+			src2[buf_size + DIF_REF_TAG_3 + dif_size] = (dif_reftag >> 8) & 0xFF;
+			src2[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;
+		break;
+
+	case DSA_OPCODE_DIF_UPDT:
+		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;
+
+		src3 = (uint8_t *)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((src3 + dif_size), tsk->pattern, buf_size);
+			dif_guardtag = dsa_calculate_crc_t10dif((src3 + dif_size), buf_size, 0);
+			src3[buf_size + DIF_BLK_GRD_1 + dif_size] = (dif_guardtag >> 8) & 0xFF;
+			src3[buf_size + DIF_BLK_GRD_2 + dif_size] = dif_guardtag & 0xFF;
+			src3[buf_size + DIF_APP_TAG_1 + dif_size] = (dif_apptag >> 8) & 0xFF;
+			src3[buf_size + DIF_APP_TAG_2 + dif_size] = (dif_apptag) & 0xFF;
+			src3[buf_size + DIF_REF_TAG_1 + dif_size] = (dif_reftag >> 24) & 0xFF;
+			src3[buf_size + DIF_REF_TAG_2 + dif_size] = (dif_reftag >> 16) & 0xFF;
+			src3[buf_size + DIF_REF_TAG_3 + dif_size] = (dif_reftag >> 8) & 0xFF;
+			src3[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;
+		break;
+
+	case DSA_OPCODE_AP_DELTA:
+	case DSA_OPCODE_CR_DELTA:
+		tsk->src1 = aligned_alloc(force_align, tsk->xfer_size);
+		if (!tsk->src1)
+			return -ENOMEM;
+		memset_pattern(tsk->src1, patternx, tsk->xfer_size);
+		tsk->src2 = aligned_alloc(force_align, tsk->xfer_size);
+		if (!tsk->src2)
+			return -ENOMEM;
+		memset_pattern(tsk->src2, patterny, 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;
+		}
+		break;
+
+	case DSA_OPCODE_CRCGEN:
+		tsk->src1 = aligned_alloc(force_align, xfer_size);
+		if (!tsk->src1)
+			return -ENOMEM;
+		memset_pattern(tsk->src1, tsk->pattern, xfer_size);
+		srand(time(0));
+		tsk->crc_seed = 0x12345678;
+		if (tsk->test_flags & (unsigned int)(READ_CRC_SEED)) {
+			tsk->crc_seed_addr = aligned_alloc(ADDR_ALIGNMENT, sizeof(tsk->crc_seed));
+			*tsk->crc_seed_addr = tsk->crc_seed;
+			tsk->crc_seed = 0x0;
+		}
+		break;
+
+	case DSA_OPCODE_COPY_CRC:
+		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);
+		srand(time(0));
+		tsk->crc_seed = 0x12345678;
+		if (tsk->test_flags & (unsigned int)(READ_CRC_SEED)) {
+			tsk->crc_seed_addr = aligned_alloc(ADDR_ALIGNMENT, sizeof(tsk->crc_seed));
+			*tsk->crc_seed_addr = tsk->crc_seed;
+			tsk->crc_seed = 0x0;
+		}
+		break;
  	}
 
  	dbg("Mem allocated: s1 %#lx s2 %#lx d1 %#lx d2 %#lx\n",
@@ -1237,6 +1477,25 @@ int task_result_verify_dualcast(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)
+{
+	uint16_t 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;
+}
+
  int batch_result_verify(struct batch_task *btsk, int bof)
  {
  	uint8_t core_stat, sub_stat;
test/dsa.h +34 -0
index 6363bbd..72c2675 100644
@@ -4,6 +4,7 @@
  #define __TEST_DSA_H__
  #include <accfg/libaccel_config.h>
  #include <accfg/idxd.h>
+#include "crc16_t10_lookup.h"
  #include "accfg_test.h"
 
  #define MAX_PATH_LENGTH 1024
@@ -41,6 +42,26 @@
  #define DSA_COMP_STAT_CODE_MASK                 0x3F
  #define DSA_COMP_STAT_RW_MASK                   0x80
 
+#define DIF_INVERT_CRC_SEED         ((unsigned long)(1 << 2))
+#define DIF_INVERT_CRC_RESULT       ((unsigned long)(1 << 3))
+
+/* 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
+
+/* 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
  /* helper macro to get lower 6 bits (ret code) from completion status */
  #define stat_val(status) ((status) & DSA_COMP_STAT_CODE_MASK)
@@ -63,6 +84,14 @@ struct task {
  	uint64_t xfer_size;
  	uint32_t dflags;
  	int test_flags;
+	int reftag;
+	int apptag;
+	int guardtag;
+	unsigned long blks;
+	int blk_idx_flg;
+	int crc_seed;
+	int delta_rec_size;
+	uint64_t *crc_seed_addr;
  };
 
  struct task_node {
@@ -306,4 +335,9 @@ 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
author
#8 lore raw

PATCH 5/9 accel-config/test: add CRC Generation and Copy with CRC Generation support

In reply to Tony Zhu

Add DSA_OPCODE_CRCGEN and DSA_OPCODE_COPY_CRC operation support.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/crc16_t10_lookup.h |  36 +++++
 test/dsa.c              | 254 +++++++++++++++++++++++++++++
 test/dsa.h              |  14 ++
 test/dsa_crc32.h        | 351 ++++++++++++++++++++++++++++++++++++++++
 test/dsa_test.c         |  81 ++++++++++
 test/prep.c             |  97 +++++++++++
 6 files changed, 833 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
new file mode 100644
index 0000000..34aac36
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright(c) 2019 Intel Corporation. All rights reserved. */
+static const uint16_t 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 +254 -0

278 lines not on this page · raw message

test/dsa.h +14 -0
index 72c2675..43f191c 100644
@@ -286,6 +286,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_memcpy(struct task *tsk);
 void dsa_reprep_memcpy(struct dsa_context *ctx, struct task *tsk);
@@ -301,6 +307,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);
@@ -309,6 +319,8 @@ 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_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);
@@ -324,6 +336,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

109 lines not on this page · raw message

Signature · 1 line
2.27.0
author
#9 lore raw

PATCH 6/9 accel-config/test: add create and apply delta record result verification

In reply to Tony Zhu

Create Delta Record verify is ignored for data, it is fine to check the completion status. For Apply Delta Record, the the source and destination values should be compared.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c | 26 ++++++++++++++++++++++++++
 test/dsa.h |  2 ++
 2 files changed, 28 insertions(+)
test/dsa.c +26 -0
index f383e42..5e617a9 100644
@@ -1471,6 +1471,12 @@ 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_CR_DELTA:
+		rc = task_result_verify_cr_delta(tsk, mismatch_expected);
+		return rc;
+	case DSA_OPCODE_AP_DELTA:
+		rc = task_result_verify_ap_delta(tsk, mismatch_expected);
+		return rc;
 	case DSA_OPCODE_CRCGEN:
 		rc = task_result_verify_crcgen(tsk, mismatch_expected);
 		return rc;
@@ -1596,6 +1602,26 @@ int task_result_verify_dualcast(struct task *tsk, int mismatch_expected)
 	return DSA_STATUS_OK;
 }
 
+int task_result_verify_cr_delta(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;
+}
+
 static uint8_t reverse_u8(uint8_t x)
 {
 	const char *rev = "\x0\x8\x4\xC\x2\xA\x6\xE\x1\x9\x5\xD\x3\xB\x7\xF";
test/dsa.h +2 -0
index 43f191c..ad86dfa 100644
@@ -319,6 +319,8 @@ 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_cr_delta(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);
Signature · 1 line
2.27.0
author
#10 lore raw

PATCH 7/9 accel-config/test: add 4 dif operations support

In reply to Tony Zhu

Add Data Integrity Field (DIF) check, insert, strip, and update while transferring data.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c      | 473 ++++++++++++++++++++++++++++++++++++++++++++++++
 test/dsa.h      |  17 ++
 test/dsa_test.c | 104 +++++++++++
 test/prep.c     | 189 +++++++++++++++++++
 4 files changed, 783 insertions(+)
test/dsa.c +473 -0
index 5e617a9..eead318 100644
@@ -1445,6 +1445,158 @@ int dsa_crc_copy_multi_task_nodes(struct dsa_context *ctx)
 	return ret;
 }
 
+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;
+}
+
+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;
+}
+
 /* mismatch_expected: expect mismatched buffer with success status 0x1 */
 int task_result_verify(struct task *tsk, int mismatch_expected)
 {
@@ -1483,6 +1635,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);
@@ -1776,6 +1941,314 @@ uint16_t dsa_calculate_crc_t10dif(unsigned char *buffer, size_t len, int flags)
 	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 +17 -0
index ad86dfa..007883e 100644
@@ -292,6 +292,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_memcpy(struct task *tsk);
 void dsa_reprep_memcpy(struct dsa_context *ctx, struct task *tsk);
@@ -311,6 +317,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);
@@ -323,6 +334,8 @@ int task_result_verify_cr_delta(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);
@@ -340,6 +353,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);
test/dsa_test.c +104 -0

122 lines not on this page · raw message

test/prep.c +189 -0

207 lines not on this page · raw message

Signature · 1 line
2.27.0
author
#11 lore raw

PATCH 8/9 accel-config/test: split drain multi task from noop multi task

In reply to Tony Zhu

Noop operation is different from drain, so add drain functions to set the test flags.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c      | 44 ++++++++++++++++++++++++++++++++++++++++++++
 test/dsa.h      |  4 ++++
 test/dsa_test.c | 20 +++++++++++++++++---
 test/prep.c     | 10 ++++++++++
 4 files changed, 75 insertions(+), 3 deletions(-)
test/dsa.c +44 -0
index eead318..ecda9a3 100644
@@ -920,6 +920,50 @@ int dsa_noop_multi_task_nodes(struct dsa_context *ctx)
 	return ret;
 }
 
+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) {
+		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_batch(struct batch_task *btsk)
 {
 	int rc;
test/dsa.h +4 -0
index 007883e..6cceb62 100644
@@ -265,6 +265,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);
 
@@ -299,6 +302,7 @@ 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);
 void dsa_reprep_memcpy(struct dsa_context *ctx, struct task *tsk);
 void dsa_prep_memfill(struct task *tsk);
test/dsa_test.c +17 -3
index 13558ec..9b56160 100644
@@ -237,9 +237,23 @@ static int test_noop_drain(struct dsa_context *ctx, int tflags, uint32_t opcode,
 			tsk_node = tsk_node->next;
 		}
 
-		rc = dsa_noop_multi_task_nodes(ctx);
-		if (rc != DSA_STATUS_OK)
-			return rc;
+		switch (opcode) {
+		case DSA_OPCODE_NOOP:
+			rc = dsa_noop_multi_task_nodes(ctx);
+			if (rc != DSA_STATUS_OK)
+				return rc;
+			break;
+
+		case DSA_OPCODE_DRAIN:
+			rc = dsa_drain_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*/
 		tsk_node = ctx->multi_task_node;
test/prep.c +10 -0
index 56c821d..48e0a7e 100644
@@ -43,6 +43,16 @@ void dsa_prep_noop(struct task *tsk)
 	tsk->comp->status = 0;
 }
 
+void dsa_prep_drain(struct task *tsk)
+{
+	info("preparing descriptor for noop\n");
+
+	dsa_prep_desc_common(tsk->desc, tsk->opcode, (uint64_t)(tsk->dst1),
+			     (uint64_t)(tsk->src1), 0, 0xc);
+	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");
Signature · 1 line
2.27.0
author
#12 lore raw

PATCH 9/9 accel-config/test: add cache flush operation support

In reply to Tony Zhu

The Cache Flush operation, 0x20, flushes the processor caches at the Destination Address.

Signed-off-by Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c      | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
 test/dsa.h      |  5 +++++
 test/dsa_test.c |  7 +++++++
 test/prep.c     | 30 ++++++++++++++++++++++++++
 4 files changed, 98 insertions(+)
test/dsa.c +56 -0
index ecda9a3..6cf7f80 100644
@@ -964,6 +964,62 @@ int dsa_drain_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;
+}
+
 int dsa_wait_batch(struct batch_task *btsk)
 {
 	int rc;
test/dsa.h +5 -0
index 6cceb62..e77f818 100644
@@ -268,6 +268,9 @@ 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_cflush_multi_task_nodes(struct dsa_context *ctx);
+int dsa_wait_cflush(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);
 
@@ -303,6 +306,8 @@ 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_cflush(struct task *tsk);
+void dsa_reprep_cflush(struct dsa_context *ctx, 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 +7 -0
index 9b56160..0de762c 100644
@@ -399,6 +399,12 @@ 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 +732,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 +30 -0
index 48e0a7e..c427109 100644
@@ -53,6 +53,36 @@ void dsa_prep_drain(struct task *tsk)
 	tsk->comp->status = 0;
 }
 
+void dsa_prep_cflush(struct task *tsk)
+{
+	info("preparing descriptor for cflush\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;
+}
+
+void dsa_reprep_cflush(struct dsa_context *ctx, struct task *tsk)
+{
+	struct dsa_completion_record *compl = tsk->comp;
+	struct dsa_hw_desc *hw = tsk->desc;
+
+	info("PF addr %#lx dir %d bc %#x\n",
+	     compl->fault_addr, compl->result,
+	     compl->bytes_completed);
+
+	hw->xfer_size -= compl->bytes_completed;
+
+	hw->src_addr += compl->bytes_completed;
+
+	resolve_page_fault(compl->fault_addr, compl->status);
+
+	compl->status = 0;
+
+	dsa_desc_submit(ctx, hw);
+}
+
 void dsa_prep_memcpy(struct task *tsk)
 {
 	info("preparing descriptor for memcpy\n");
Signature · 1 line
2.27.0
#13 lore raw
In reply to Tony Zhu
Quoted 2 lines · Tony Zhu

Only has memory opocde operation support, add other opcode code support to cover all.

Complete sentences please. :)

dsa_test only has memory opcode operations supported. Add the missing opcodes support to cover all DSA 1.0 operations.

Quoted 25 lines

Tony Zhu (9):
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 pattern2 to fill destination buffers accel-config/test: rewrite init task and add the init of dif
operations
accel-config/test: add CRC Generation and Copy with CRC Generation
support
accel-config/test: add create and apply delta record result
verification
accel-config/test: add 4 dif operations support accel-config/test: split drain multi task from noop multi task accel-config/test: add cache flush operation support

  test/crc16_t10_lookup.h |   36 ++
  test/dsa.c              | 1349 +++++++++++++++++++++++++++++++++++++--
  test/dsa.h              |   91 +++
  test/dsa_crc32.h        |  351 ++++++++++
  test/dsa_test.c         |  345 +++++++++-
  test/prep.c             |  442 +++++++++++++
  6 files changed, 2544 insertions(+), 70 deletions(-)

create mode 100644 test/crc16_t10_lookup.h
create mode 100644 test/dsa_crc32.h