From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: kevin.laatz@intel.com, sunil.pai.g@intel.com, jiayu.hu@intel.com,
Bruce Richardson <bruce.richardson@intel.com>
Subject: [dpdk-dev] [PATCH v5 01/12] raw/ioat: add unit tests for completion batching
Date: Tue, 4 May 2021 14:14:47 +0100 [thread overview]
Message-ID: <20210504131458.593429-2-bruce.richardson@intel.com> (raw)
In-Reply-To: <20210504131458.593429-1-bruce.richardson@intel.com>
Add in additional unit tests to verify that we can get completion reports
of multiple batches in a single completed_ops() call. Also verify we can
get smaller number of completions if that is requested too.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/raw/ioat/ioat_rawdev_test.c | 199 +++++++++++++++++++---------
1 file changed, 137 insertions(+), 62 deletions(-)
diff --git a/drivers/raw/ioat/ioat_rawdev_test.c b/drivers/raw/ioat/ioat_rawdev_test.c
index 101f24a677..a5064d739d 100644
--- a/drivers/raw/ioat/ioat_rawdev_test.c
+++ b/drivers/raw/ioat/ioat_rawdev_test.c
@@ -11,6 +11,7 @@
#define MAX_SUPPORTED_RAWDEVS 64
#define TEST_SKIPPED 77
+#define COPY_LEN 1024
int ioat_rawdev_test(uint16_t dev_id); /* pre-define to keep compiler happy */
@@ -34,32 +35,114 @@ print_err(const char *func, int lineno, const char *format, ...)
return ret;
}
+static int
+do_multi_copies(int dev_id, int split_batches, int split_completions)
+{
+ struct rte_mbuf *srcs[32], *dsts[32];
+ struct rte_mbuf *completed_src[64];
+ struct rte_mbuf *completed_dst[64];
+ unsigned int i, j;
+
+ for (i = 0; i < RTE_DIM(srcs); i++) {
+ char *src_data;
+
+ if (split_batches && i == RTE_DIM(srcs) / 2)
+ rte_ioat_perform_ops(dev_id);
+
+ srcs[i] = rte_pktmbuf_alloc(pool);
+ dsts[i] = rte_pktmbuf_alloc(pool);
+ src_data = rte_pktmbuf_mtod(srcs[i], char *);
+
+ for (j = 0; j < COPY_LEN; j++)
+ src_data[j] = rand() & 0xFF;
+
+ if (rte_ioat_enqueue_copy(dev_id,
+ srcs[i]->buf_iova + srcs[i]->data_off,
+ dsts[i]->buf_iova + dsts[i]->data_off,
+ COPY_LEN,
+ (uintptr_t)srcs[i],
+ (uintptr_t)dsts[i]) != 1) {
+ PRINT_ERR("Error with rte_ioat_enqueue_copy for buffer %u\n",
+ i);
+ return -1;
+ }
+ }
+ rte_ioat_perform_ops(dev_id);
+ usleep(100);
+
+ if (split_completions) {
+ /* gather completions in two halves */
+ uint16_t half_len = RTE_DIM(srcs) / 2;
+ if (rte_ioat_completed_ops(dev_id, half_len, (void *)completed_src,
+ (void *)completed_dst) != half_len) {
+ PRINT_ERR("Error with rte_ioat_completed_ops - first half request\n");
+ rte_rawdev_dump(dev_id, stdout);
+ return -1;
+ }
+ if (rte_ioat_completed_ops(dev_id, half_len, (void *)&completed_src[half_len],
+ (void *)&completed_dst[half_len]) != half_len) {
+ PRINT_ERR("Error with rte_ioat_completed_ops - second half request\n");
+ rte_rawdev_dump(dev_id, stdout);
+ return -1;
+ }
+ } else {
+ /* gather all completions in one go */
+ if (rte_ioat_completed_ops(dev_id, 64, (void *)completed_src,
+ (void *)completed_dst) != RTE_DIM(srcs)) {
+ PRINT_ERR("Error with rte_ioat_completed_ops\n");
+ rte_rawdev_dump(dev_id, stdout);
+ return -1;
+ }
+ }
+ for (i = 0; i < RTE_DIM(srcs); i++) {
+ char *src_data, *dst_data;
+
+ if (completed_src[i] != srcs[i]) {
+ PRINT_ERR("Error with source pointer %u\n", i);
+ return -1;
+ }
+ if (completed_dst[i] != dsts[i]) {
+ PRINT_ERR("Error with dest pointer %u\n", i);
+ return -1;
+ }
+
+ src_data = rte_pktmbuf_mtod(srcs[i], char *);
+ dst_data = rte_pktmbuf_mtod(dsts[i], char *);
+ for (j = 0; j < COPY_LEN; j++)
+ if (src_data[j] != dst_data[j]) {
+ PRINT_ERR("Error with copy of packet %u, byte %u\n",
+ i, j);
+ return -1;
+ }
+ rte_pktmbuf_free(srcs[i]);
+ rte_pktmbuf_free(dsts[i]);
+ }
+ return 0;
+}
+
static int
test_enqueue_copies(int dev_id)
{
- const unsigned int length = 1024;
unsigned int i;
+ /* test doing a single copy */
do {
struct rte_mbuf *src, *dst;
char *src_data, *dst_data;
struct rte_mbuf *completed[2] = {0};
- /* test doing a single copy */
src = rte_pktmbuf_alloc(pool);
dst = rte_pktmbuf_alloc(pool);
- src->data_len = src->pkt_len = length;
- dst->data_len = dst->pkt_len = length;
src_data = rte_pktmbuf_mtod(src, char *);
dst_data = rte_pktmbuf_mtod(dst, char *);
- for (i = 0; i < length; i++)
+ for (i = 0; i < COPY_LEN; i++)
src_data[i] = rand() & 0xFF;
if (rte_ioat_enqueue_copy(dev_id,
src->buf_iova + src->data_off,
dst->buf_iova + dst->data_off,
- length,
+ COPY_LEN,
(uintptr_t)src,
(uintptr_t)dst) != 1) {
PRINT_ERR("Error with rte_ioat_enqueue_copy\n");
@@ -79,99 +162,91 @@ test_enqueue_copies(int dev_id)
return -1;
}
- for (i = 0; i < length; i++)
+ for (i = 0; i < COPY_LEN; i++)
if (dst_data[i] != src_data[i]) {
- PRINT_ERR("Data mismatch at char %u\n", i);
+ PRINT_ERR("Data mismatch at char %u [Got %02x not %02x]\n",
+ i, dst_data[i], src_data[i]);
return -1;
}
rte_pktmbuf_free(src);
rte_pktmbuf_free(dst);
} while (0);
- /* test doing multiple copies */
+ /* test doing a multiple single copies */
do {
- struct rte_mbuf *srcs[32], *dsts[32];
- struct rte_mbuf *completed_src[64];
- struct rte_mbuf *completed_dst[64];
- unsigned int j;
-
- for (i = 0; i < RTE_DIM(srcs); i++) {
- char *src_data;
+ const uint16_t max_ops = 4;
+ struct rte_mbuf *src, *dst;
+ char *src_data, *dst_data;
+ struct rte_mbuf *completed[32] = {0};
+ const uint16_t max_completions = RTE_DIM(completed) / 2;
- srcs[i] = rte_pktmbuf_alloc(pool);
- dsts[i] = rte_pktmbuf_alloc(pool);
- srcs[i]->data_len = srcs[i]->pkt_len = length;
- dsts[i]->data_len = dsts[i]->pkt_len = length;
- src_data = rte_pktmbuf_mtod(srcs[i], char *);
+ src = rte_pktmbuf_alloc(pool);
+ dst = rte_pktmbuf_alloc(pool);
+ src_data = rte_pktmbuf_mtod(src, char *);
+ dst_data = rte_pktmbuf_mtod(dst, char *);
- for (j = 0; j < length; j++)
- src_data[j] = rand() & 0xFF;
+ for (i = 0; i < COPY_LEN; i++)
+ src_data[i] = rand() & 0xFF;
+ /* perform the same copy <max_ops> times */
+ for (i = 0; i < max_ops; i++) {
if (rte_ioat_enqueue_copy(dev_id,
- srcs[i]->buf_iova + srcs[i]->data_off,
- dsts[i]->buf_iova + dsts[i]->data_off,
- length,
- (uintptr_t)srcs[i],
- (uintptr_t)dsts[i]) != 1) {
- PRINT_ERR("Error with rte_ioat_enqueue_copy for buffer %u\n",
- i);
+ src->buf_iova + src->data_off,
+ dst->buf_iova + dst->data_off,
+ COPY_LEN,
+ (uintptr_t)src,
+ (uintptr_t)dst) != 1) {
+ PRINT_ERR("Error with rte_ioat_enqueue_copy\n");
return -1;
}
+ rte_ioat_perform_ops(dev_id);
}
- rte_ioat_perform_ops(dev_id);
- usleep(100);
+ usleep(10);
- if (rte_ioat_completed_ops(dev_id, 64, (void *)completed_src,
- (void *)completed_dst) != RTE_DIM(srcs)) {
+ if (rte_ioat_completed_ops(dev_id, max_completions, (void *)&completed[0],
+ (void *)&completed[max_completions]) != max_ops) {
PRINT_ERR("Error with rte_ioat_completed_ops\n");
return -1;
}
- for (i = 0; i < RTE_DIM(srcs); i++) {
- char *src_data, *dst_data;
+ if (completed[0] != src || completed[max_completions] != dst) {
+ PRINT_ERR("Error with completions: got (%p, %p), not (%p,%p)\n",
+ completed[0], completed[max_completions], src, dst);
+ return -1;
+ }
- if (completed_src[i] != srcs[i]) {
- PRINT_ERR("Error with source pointer %u\n", i);
- return -1;
- }
- if (completed_dst[i] != dsts[i]) {
- PRINT_ERR("Error with dest pointer %u\n", i);
+ for (i = 0; i < COPY_LEN; i++)
+ if (dst_data[i] != src_data[i]) {
+ PRINT_ERR("Data mismatch at char %u\n", i);
return -1;
}
-
- src_data = rte_pktmbuf_mtod(srcs[i], char *);
- dst_data = rte_pktmbuf_mtod(dsts[i], char *);
- for (j = 0; j < length; j++)
- if (src_data[j] != dst_data[j]) {
- PRINT_ERR("Error with copy of packet %u, byte %u\n",
- i, j);
- return -1;
- }
- rte_pktmbuf_free(srcs[i]);
- rte_pktmbuf_free(dsts[i]);
- }
-
+ rte_pktmbuf_free(src);
+ rte_pktmbuf_free(dst);
} while (0);
+ /* test doing multiple copies */
+ do_multi_copies(dev_id, 0, 0); /* enqueue and complete one batch at a time */
+ do_multi_copies(dev_id, 1, 0); /* enqueue 2 batches and then complete both */
+ do_multi_copies(dev_id, 0, 1); /* enqueue 1 batch, then complete in two halves */
return 0;
}
static int
test_enqueue_fill(int dev_id)
{
- const unsigned int length[] = {8, 64, 1024, 50, 100, 89};
+ const unsigned int lengths[] = {8, 64, 1024, 50, 100, 89};
struct rte_mbuf *dst = rte_pktmbuf_alloc(pool);
char *dst_data = rte_pktmbuf_mtod(dst, char *);
struct rte_mbuf *completed[2] = {0};
uint64_t pattern = 0xfedcba9876543210;
unsigned int i, j;
- for (i = 0; i < RTE_DIM(length); i++) {
+ for (i = 0; i < RTE_DIM(lengths); i++) {
/* reset dst_data */
- memset(dst_data, 0, length[i]);
+ memset(dst_data, 0, lengths[i]);
/* perform the fill operation */
if (rte_ioat_enqueue_fill(dev_id, pattern,
- dst->buf_iova + dst->data_off, length[i],
+ dst->buf_iova + dst->data_off, lengths[i],
(uintptr_t)dst) != 1) {
PRINT_ERR("Error with rte_ioat_enqueue_fill\n");
return -1;
@@ -186,11 +261,11 @@ test_enqueue_fill(int dev_id)
return -1;
}
/* check the result */
- for (j = 0; j < length[i]; j++) {
+ for (j = 0; j < lengths[i]; j++) {
char pat_byte = ((char *)&pattern)[j % 8];
if (dst_data[j] != pat_byte) {
- PRINT_ERR("Error with fill operation (length = %u): got (%x), not (%x)\n",
- length[i], dst_data[j],
+ PRINT_ERR("Error with fill operation (lengths = %u): got (%x), not (%x)\n",
+ lengths[i], dst_data[j],
pat_byte);
return -1;
}
--
2.30.2
next prev parent reply other threads:[~2021-05-04 13:16 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-18 18:20 [dpdk-dev] [PATCH v1 0/6] ioat driver updates Bruce Richardson
2021-03-18 18:20 ` [dpdk-dev] [PATCH v1 1/6] raw/ioat: support limiting queues for idxd PCI device Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 00/12] ioat driver updates Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 01/12] raw/ioat: add unit tests for completion batching Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 02/12] raw/ioat: support limiting queues for idxd PCI device Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 03/12] raw/ioat: add component prefix to log messages Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 04/12] raw/ioat: add explicit padding to descriptor struct Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 05/12] raw/ioat: fix script for configuring small number of queues Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 06/12] raw/ioat: make workqueue name configurable in script Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 07/12] raw/ioat: allow perform operations function to return error Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 08/12] raw/ioat: add bus driver for device scanning automatically Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 09/12] raw/ioat: move idxd functions to separate file Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 10/12] raw/ioat: rework SW ring layout Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 11/12] raw/ioat: add API to query remaining ring space Bruce Richardson
2021-04-26 9:52 ` [dpdk-dev] [PATCH v2 12/12] raw/ioat: report status of completed jobs Bruce Richardson
2021-03-18 18:20 ` [dpdk-dev] [PATCH v1 2/6] raw/ioat: add component prefix to log messages Bruce Richardson
2021-03-18 18:20 ` [dpdk-dev] [PATCH v1 3/6] raw/ioat: add explicit padding to descriptor struct Bruce Richardson
2021-03-18 18:20 ` [dpdk-dev] [PATCH v1 4/6] raw/ioat: rework SW ring layout Bruce Richardson
2021-03-18 18:20 ` [dpdk-dev] [PATCH v1 5/6] raw/ioat: add api to query remaining ring space Bruce Richardson
2021-03-29 7:51 ` Pai G, Sunil
2021-03-18 18:20 ` [dpdk-dev] [PATCH v1 6/6] raw/ioat: add bus driver for device scanning automatically Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 00/12] ioat driver updates Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 01/12] raw/ioat: add unit tests for completion batching Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 02/12] raw/ioat: support limiting queues for idxd PCI device Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 03/12] raw/ioat: add component prefix to log messages Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 04/12] raw/ioat: add explicit padding to descriptor struct Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 05/12] raw/ioat: fix script for configuring small number of queues Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 06/12] raw/ioat: make workqueue name configurable in script Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 07/12] raw/ioat: allow perform operations function to return error Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 08/12] raw/ioat: add bus driver for device scanning automatically Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 09/12] raw/ioat: move idxd functions to separate file Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 10/12] raw/ioat: rework SW ring layout Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 11/12] raw/ioat: add API to query remaining ring space Bruce Richardson
2021-04-30 11:17 ` [dpdk-dev] [PATCH v3 12/12] raw/ioat: report status of completed jobs Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 00/12] ioat driver updates Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 01/12] raw/ioat: add unit tests for completion batching Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 02/12] raw/ioat: support limiting queues for idxd PCI device Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 03/12] raw/ioat: add component prefix to log messages Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 04/12] raw/ioat: add explicit padding to descriptor struct Bruce Richardson
2021-05-03 21:20 ` Thomas Monjalon
2021-05-04 12:04 ` Bruce Richardson
2021-05-04 12:16 ` Thomas Monjalon
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 05/12] raw/ioat: fix script for configuring small number of queues Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 06/12] raw/ioat: make workqueue name configurable in script Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 07/12] raw/ioat: allow perform operations function to return error Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 08/12] raw/ioat: add bus driver for device scanning automatically Bruce Richardson
2021-05-03 21:32 ` Thomas Monjalon
2021-05-04 12:07 ` Bruce Richardson
2021-05-04 12:19 ` Thomas Monjalon
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 09/12] raw/ioat: move idxd functions to separate file Bruce Richardson
2021-05-03 21:35 ` Thomas Monjalon
2021-05-04 12:08 ` Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 10/12] raw/ioat: rework SW ring layout Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 11/12] raw/ioat: add API to query remaining ring space Bruce Richardson
2021-04-30 15:06 ` [dpdk-dev] [PATCH v4 12/12] raw/ioat: report status of completed jobs Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 00/12] ioat driver updates Bruce Richardson
2021-05-04 13:14 ` Bruce Richardson [this message]
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 02/12] raw/ioat: support limiting queues for idxd PCI device Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 03/12] raw/ioat: add component prefix to log messages Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 04/12] raw/ioat: expand descriptor struct to full 64 bytes Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 05/12] raw/ioat: fix script for configuring small number of queues Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 06/12] raw/ioat: make workqueue name configurable in script Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 07/12] raw/ioat: allow perform operations function to return error Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 08/12] raw/ioat: add bus driver for device scanning automatically Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 09/12] raw/ioat: move idxd functions to separate file Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 10/12] raw/ioat: rework SW ring layout Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 11/12] raw/ioat: add API to query remaining ring space Bruce Richardson
2021-05-04 13:14 ` [dpdk-dev] [PATCH v5 12/12] raw/ioat: report status of completed jobs Bruce Richardson
2021-05-04 16:17 ` [dpdk-dev] [PATCH v5 00/12] ioat driver updates Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210504131458.593429-2-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=jiayu.hu@intel.com \
--cc=kevin.laatz@intel.com \
--cc=sunil.pai.g@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).