All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v2 1/1] accel-config:dsa_test Add no opcode operation support
@ 2021-08-27  3:14 Tony Zhu
  0 siblings, 0 replies; only message in thread
From: Tony Zhu @ 2021-08-27  3:14 UTC (permalink / raw)
  To: accel-config

[-- Attachment #1: Type: text/plain, Size: 4925 bytes --]

The No-op operation performs no DMA operation. Add the test support.

Signed-off-by: Tony Zhu <tony.zhu(a)intel.com>
---
 test/dsa.c      | 28 ++++++++++++++++++++++++++++
 test/dsa.h      |  5 +++++
 test/dsa_test.c | 30 ++++++++++++++++++++++++++++++
 test/prep.c     | 28 ++++++++++++++++++++++++++++
 4 files changed, 91 insertions(+)

diff --git a/test/dsa.c b/test/dsa.c
index 5396b1b..ce6f6a1 100644
--- a/test/dsa.c
+++ b/test/dsa.c
@@ -554,6 +554,34 @@ void free_batch_task(struct batch_task *btsk)
 	free(btsk);
 }
 
+int dsa_wait_noop(struct dsa_context *ctx)
+{
+	struct dsa_completion_record *comp = ctx->single_task->comp;
+	int rc;
+
+	rc = dsa_wait_on_desc_timeout(comp, ms_timeout);
+	if (rc < 0) {
+		err("noop desc timeout\n");
+		return DSA_STATUS_TIMEOUT;
+	}
+
+	return DSA_STATUS_OK;
+}
+
+int dsa_noop(struct dsa_context *ctx)
+{
+	struct task *tsk = ctx->single_task;
+	int ret = DSA_STATUS_OK;
+
+	tsk->dflags = IDXD_OP_FLAG_CRAV | IDXD_OP_FLAG_RCR;
+
+	dsa_prep_noop(tsk);
+	dsa_desc_submit(ctx, tsk->desc);
+	ret = dsa_wait_noop(ctx);
+
+	return ret;
+}
+
 int dsa_wait_batch(struct dsa_context *ctx)
 {
 	int rc;
diff --git a/test/dsa.h b/test/dsa.h
index 4e3cddc..5db0c02 100644
--- a/test/dsa.h
+++ b/test/dsa.h
@@ -217,6 +217,9 @@ struct task *__alloc_task(void);
 int init_task(struct task *tsk, int tflags, int opcode,
 		unsigned long xfer_size);
 
+int dsa_noop(struct dsa_context *ctx);
+int dsa_wait_noop(struct dsa_context *ctx);
+
 int dsa_memcpy(struct dsa_context *ctx);
 int dsa_wait_memcpy(struct dsa_context *ctx);
 
@@ -232,6 +235,7 @@ int dsa_wait_compval(struct dsa_context *ctx);
 int dsa_dualcast(struct dsa_context *ctx);
 int dsa_wait_dualcast(struct dsa_context *ctx);
 
+void dsa_prep_noop(struct task *tsk);
 void dsa_prep_memcpy(struct task *tsk);
 void dsa_reprep_memcpy(struct dsa_context *ctx);
 void dsa_prep_memfill(struct task *tsk);
@@ -256,6 +260,7 @@ int init_batch_task(struct batch_task *btsk, int task_num, int tflags,
 		int opcode, unsigned long xfer_size, unsigned long dflags);
 
 void dsa_prep_batch(struct batch_task *btsk, unsigned long desc_flags);
+void dsa_prep_batch_noop(struct batch_task *btsk);
 void dsa_prep_batch_memcpy(struct batch_task *btsk);
 void dsa_prep_batch_memfill(struct batch_task *btsk);
 void dsa_prep_batch_compare(struct batch_task *btsk);
diff --git a/test/dsa_test.c b/test/dsa_test.c
index 90be118..5f7a7f1 100644
--- a/test/dsa_test.c
+++ b/test/dsa_test.c
@@ -58,6 +58,9 @@ static int test_batch(struct dsa_context *ctx, size_t buf_size,
 		return rc;
 
 	switch (bopcode) {
+	case DSA_OPCODE_NOOP:
+		dsa_prep_batch_noop(ctx->batch_task);
+		break;
 	case DSA_OPCODE_MEMMOVE:
 		dsa_prep_batch_memcpy(ctx->batch_task);
 		break;
@@ -157,6 +160,33 @@ int main(int argc, char *argv[])
 	}
 
 	switch (opcode) {
+	case DSA_OPCODE_NOOP: {
+		struct task *tsk;
+
+		info("noop: len %#lx tflags %#x\n", buf_size, tflags);
+
+		rc = alloc_task(dsa);
+		if (rc != DSA_STATUS_OK) {
+			err("noop: alloc task failed, rc=%d\n", rc);
+			goto error;
+		}
+
+		tsk = dsa->single_task;
+
+		rc = dsa_noop(dsa);
+		if (rc != DSA_STATUS_OK) {
+			err("noop failed stat %d\n", rc);
+			rc = -ENXIO;
+			break;
+		}
+
+		rc = task_result_verify(tsk, 0);
+		if (rc != DSA_STATUS_OK)
+			goto error;
+
+		break;
+	}
+
 	case DSA_OPCODE_BATCH:
 		if (bsize > dsa->max_batch_size || bsize < 2) {
 			err("invalid num descs: %d\n", bsize);
diff --git a/test/prep.c b/test/prep.c
index bb06626..f22f190 100644
--- a/test/prep.c
+++ b/test/prep.c
@@ -30,6 +30,17 @@ void dsa_desc_submit(struct dsa_context *ctx, struct dsa_hw_desc *hw)
 			usleep(10000);
 }
 
+void dsa_prep_noop(struct task *tsk)
+{
+	info("preparing descriptor for noop\n");
+
+	tsk->dflags = IDXD_OP_FLAG_CRAV | IDXD_OP_FLAG_RCR;
+	dsa_prep_desc_common(tsk->desc, tsk->opcode, (uint64_t)(tsk->dst1),
+			(uint64_t)(tsk->src1), 0, tsk->dflags);
+	tsk->desc->completion_addr = (uint64_t)(tsk->comp);
+	tsk->comp->status = 0;
+}
+
 void dsa_prep_memcpy(struct task *tsk)
 {
 	info("preparing descriptor for memcpy\n");
@@ -63,6 +74,23 @@ void dsa_reprep_memcpy(struct dsa_context *ctx)
 	dsa_desc_submit(ctx, hw);
 }
 
+void dsa_prep_batch_noop(struct batch_task *btsk)
+{
+	int i;
+	struct task *sub_task;
+
+	uint32_t dflags = IDXD_OP_FLAG_CRAV | IDXD_OP_FLAG_RCR;
+	for (i = 0; i < btsk->task_num; i++) {
+		sub_task = &(btsk->sub_tasks[i]);
+		dsa_prep_desc_common(sub_task->desc, sub_task->opcode,
+				(uint64_t)(sub_task->dst1),
+				(uint64_t)(sub_task->src1),
+				0, dflags);
+		sub_task->desc->completion_addr = (uint64_t)(sub_task->comp);
+		sub_task->comp->status = 0;
+	}
+}
+
 /* Performs no error or bound checking */
 void dsa_prep_batch_memcpy(struct batch_task *btsk)
 {
-- 
2.27.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-27  3:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27  3:14 [Accel-config] [PATCH v2 1/1] accel-config:dsa_test Add no opcode operation support Tony Zhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.