get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/95430/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 95430,
    "url": "http://patchwork.dpdk.org/api/patches/95430/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20210706202841.661302-10-bruce.richardson@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patchwork.dpdk.org/api/projects/1/?format=api",
        "name": "DPDK",
        "link_name": "dpdk",
        "list_id": "dev.dpdk.org",
        "list_email": "dev@dpdk.org",
        "web_url": "http://core.dpdk.org",
        "scm_url": "git://dpdk.org/dpdk",
        "webscm_url": "http://git.dpdk.org/dpdk",
        "list_archive_url": "https://inbox.dpdk.org/dev",
        "list_archive_url_format": "https://inbox.dpdk.org/dev/{}",
        "commit_url_format": ""
    },
    "msgid": "<20210706202841.661302-10-bruce.richardson@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20210706202841.661302-10-bruce.richardson@intel.com",
    "date": "2021-07-06T20:28:41",
    "name": "[RFC,UPDATE,9/9] app/test: add basic dmadev unit test",
    "commit_ref": null,
    "pull_url": null,
    "state": "rfc",
    "archived": true,
    "hash": "1cf21f74fbbfb7e83a6c702a01abebf3f1b8a552",
    "submitter": {
        "id": 20,
        "url": "http://patchwork.dpdk.org/api/people/20/?format=api",
        "name": "Bruce Richardson",
        "email": "bruce.richardson@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20210706202841.661302-10-bruce.richardson@intel.com/mbox/",
    "series": [
        {
            "id": 17674,
            "url": "http://patchwork.dpdk.org/api/series/17674/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=17674",
            "date": "2021-07-06T20:28:32",
            "name": "dmadev rfc suggested updates",
            "version": 1,
            "mbox": "http://patchwork.dpdk.org/series/17674/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/95430/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/95430/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@inbox.dpdk.org",
        "Delivered-To": "patchwork@inbox.dpdk.org",
        "Received": [
            "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id CCA3EA0C48;\n\tTue,  6 Jul 2021 22:29:54 +0200 (CEST)",
            "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id 69AC44140A;\n\tTue,  6 Jul 2021 22:29:23 +0200 (CEST)",
            "from mga18.intel.com (mga18.intel.com [134.134.136.126])\n by mails.dpdk.org (Postfix) with ESMTP id 1C8A141424\n for <dev@dpdk.org>; Tue,  6 Jul 2021 22:29:19 +0200 (CEST)",
            "from fmsmga003.fm.intel.com ([10.253.24.29])\n by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 06 Jul 2021 13:29:19 -0700",
            "from silpixa00399126.ir.intel.com ([10.237.223.29])\n by FMSMGA003.fm.intel.com with ESMTP; 06 Jul 2021 13:29:17 -0700"
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6200,9189,10037\"; a=\"196470365\"",
            "E=Sophos;i=\"5.83,329,1616482800\"; d=\"scan'208\";a=\"196470365\"",
            "E=Sophos;i=\"5.83,329,1616482800\"; d=\"scan'208\";a=\"486522098\""
        ],
        "X-ExtLoop1": "1",
        "From": "Bruce Richardson <bruce.richardson@intel.com>",
        "To": "dev@dpdk.org",
        "Cc": "Chengwen Feng <fengchengwen@huawei.com>,\n Jerin Jacob <jerinjacobk@gmail.com>, Jerin Jacob <jerinj@marvell.com>,\n\t=?utf-8?q?Morten_Br=C3=B8rup?= <mb@smartsharesystems.com>,\n Bruce Richardson <bruce.richardson@intel.com>",
        "Date": "Tue,  6 Jul 2021 21:28:41 +0100",
        "Message-Id": "<20210706202841.661302-10-bruce.richardson@intel.com>",
        "X-Mailer": "git-send-email 2.30.2",
        "In-Reply-To": "<20210706202841.661302-1-bruce.richardson@intel.com>",
        "References": "<1625231891-2963-1-git-send-email-fengchengwen@huawei.com>\n <20210706202841.661302-1-bruce.richardson@intel.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[dpdk-dev] [RFC UPDATE PATCH 9/9] app/test: add basic dmadev unit\n test",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.29",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add in some basic dmadev unit tests for testing drivers and the library\nitself.\n\nSigned-off-by: Bruce Richardson <bruce.richardson@intel.com>\n---\n app/test/meson.build   |   2 +\n app/test/test_dmadev.c | 320 +++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 322 insertions(+)\n create mode 100644 app/test/test_dmadev.c",
    "diff": "diff --git a/app/test/meson.build b/app/test/meson.build\nindex 0a5f42557..223ca210a 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -36,6 +36,7 @@ test_sources = files(\n         'test_debug.c',\n         'test_distributor.c',\n         'test_distributor_perf.c',\n+        'test_dmadev.c',\n         'test_eal_flags.c',\n         'test_eal_fs.c',\n         'test_efd.c',\n@@ -155,6 +156,7 @@ test_deps = [\n         'cmdline',\n         'cryptodev',\n         'distributor',\n+        'dmadev',\n         'efd',\n         'ethdev',\n         'eventdev',\ndiff --git a/app/test/test_dmadev.c b/app/test/test_dmadev.c\nnew file mode 100644\nindex 000000000..df301b385\n--- /dev/null\n+++ b/app/test/test_dmadev.c\n@@ -0,0 +1,320 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright 2021 Intel Corporation\n+ */\n+\n+#include <unistd.h>\n+\n+#include <rte_mbuf.h>\n+#include <rte_dmadev.h>\n+#include \"test.h\"\n+\n+#define COPY_LEN 1024\n+\n+static struct rte_mempool *pool;\n+static uint16_t id_count = 0;\n+\n+#define PRINT_ERR(...) print_err(__func__, __LINE__, __VA_ARGS__)\n+\n+static inline int\n+__rte_format_printf(3, 4)\n+print_err(const char *func, int lineno, const char *format, ...)\n+{\n+\tva_list ap;\n+\tint ret;\n+\n+\tret = fprintf(stderr, \"In %s:%d - \", func, lineno);\n+\tva_start(ap, format);\n+\tret += vfprintf(stderr, format, ap);\n+\tva_end(ap);\n+\n+\treturn ret;\n+}\n+\n+static int\n+do_multi_copies(int dev_id, int split_batches, int split_completions)\n+{\n+\tstruct rte_mbuf *srcs[32], *dsts[32];\n+\tunsigned int i, j;\n+\tbool dma_err = false;\n+\n+\tfor (i = 0; i < RTE_DIM(srcs); i++) {\n+\t\tchar *src_data;\n+\n+\t\tif (split_batches && i == RTE_DIM(srcs) / 2)\n+\t\t\trte_dmadev_perform(dev_id, 0);\n+\n+\t\tsrcs[i] = rte_pktmbuf_alloc(pool);\n+\t\tdsts[i] = rte_pktmbuf_alloc(pool);\n+\t\tsrc_data = rte_pktmbuf_mtod(srcs[i], char *);\n+\t\tif (srcs[i] == NULL || dsts[i] == NULL) {\n+\t\t\tPRINT_ERR(\"Error allocating buffers\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tfor (j = 0; j < COPY_LEN; j++)\n+\t\t\tsrc_data[j] = rand() & 0xFF;\n+\n+\t\tif (rte_dmadev_copy(dev_id, 0, srcs[i]->buf_iova + srcs[i]->data_off,\n+\t\t\t\tdsts[i]->buf_iova + dsts[i]->data_off, COPY_LEN, 0) != id_count++) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_copy for buffer %u\\n\", i);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\trte_dmadev_perform(dev_id, 0);\n+\tusleep(100);\n+\n+\tif (split_completions) {\n+\t\t/* gather completions in two halves */\n+\t\tuint16_t half_len = RTE_DIM(srcs) / 2;\n+\t\tint ret = rte_dmadev_completed(dev_id, 0, half_len, NULL, &dma_err);\n+\t\tif (ret != half_len || dma_err) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_completed - first half. ret = %d, expected ret = %u, dma_err = %d\\n\",\n+\t\t\t\t\tret, half_len, dma_err);\n+\t\t\trte_dmadev_dump(dev_id, stdout);\n+\t\t\treturn -1;\n+\t\t}\n+\t\tret = rte_dmadev_completed(dev_id, 0, half_len, NULL, &dma_err);\n+\t\tif (ret != half_len || dma_err) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_completed - second half. ret = %d, expected ret = %u, dma_err = %d\\n\",\n+\t\t\t\t\tret, half_len, dma_err);\n+\t\t\trte_dmadev_dump(dev_id, stdout);\n+\t\t\treturn -1;\n+\t\t}\n+\t} else {\n+\t\t/* gather all completions in one go */\n+\t\tif ((j = rte_dmadev_completed(dev_id, 0, RTE_DIM(srcs), NULL,\n+\t\t\t\t&dma_err)) != RTE_DIM(srcs) || dma_err) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_completed, %u [expected: %zu], dma_err = %d\\n\",\n+\t\t\t\t\tj, RTE_DIM(srcs), dma_err);\n+\t\t\trte_dmadev_dump(dev_id, stdout);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\t/* check for empty */\n+\tif (rte_dmadev_completed(dev_id, 0, RTE_DIM(srcs), NULL, &dma_err) != 0 || dma_err) {\n+\t\tPRINT_ERR(\"Error with rte_dmadev_completed - ops unexpectedly returned\\n\");\n+\t\trte_dmadev_dump(dev_id, stdout);\n+\t\treturn -1;\n+\t}\n+\n+\tfor (i = 0; i < RTE_DIM(srcs); i++) {\n+\t\tchar *src_data, *dst_data;\n+\n+\t\tsrc_data = rte_pktmbuf_mtod(srcs[i], char *);\n+\t\tdst_data = rte_pktmbuf_mtod(dsts[i], char *);\n+\t\tfor (j = 0; j < COPY_LEN; j++)\n+\t\t\tif (src_data[j] != dst_data[j]) {\n+\t\t\t\tPRINT_ERR(\"Error with copy of packet %u, byte %u\\n\", i, j);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\trte_pktmbuf_free(srcs[i]);\n+\t\trte_pktmbuf_free(dsts[i]);\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+test_enqueue_copies(int dev_id)\n+{\n+\tunsigned int i;\n+\tuint16_t id;\n+\n+\t/* test doing a single copy */\n+\tdo {\n+\t\tstruct rte_mbuf *src, *dst;\n+\t\tchar *src_data, *dst_data;\n+\n+\t\tsrc = rte_pktmbuf_alloc(pool);\n+\t\tdst = rte_pktmbuf_alloc(pool);\n+\t\tsrc_data = rte_pktmbuf_mtod(src, char *);\n+\t\tdst_data = rte_pktmbuf_mtod(dst, char *);\n+\n+\t\tfor (i = 0; i < COPY_LEN; i++)\n+\t\t\tsrc_data[i] = rand() & 0xFF;\n+\n+\t\tid = rte_dmadev_copy(dev_id, 0, src->buf_iova + src->data_off,\n+\t\t\t\tdst->buf_iova + dst->data_off, COPY_LEN, 0);\n+\t\tif (id != id_count) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_copy, got %u, expected %u\\n\",\n+\t\t\t\t\tid, id_count);\n+\t\t\treturn -1;\n+\t\t}\n+\t\tif (rte_dmadev_perform(dev_id, 0) < 0) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_perform\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\t/* give time for copy to finish, then check it was done */\n+\t\tusleep(10);\n+\n+\t\tfor (i = 0; i < COPY_LEN; i++) {\n+\t\t\tif (dst_data[i] != src_data[i]) {\n+\t\t\t\tPRINT_ERR(\"Data mismatch at char %u [Got %02x not %02x]\\n\", i,\n+\t\t\t\t\t\tdst_data[i], src_data[i]);\n+\t\t\t\trte_dmadev_dump(dev_id, stderr);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t}\n+\n+\t\t/* now check completion works */\n+\t\tif (rte_dmadev_completed(dev_id, 0, 1, &id, NULL) != 1) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_completed\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tif (id != id_count) {\n+\t\t\tPRINT_ERR(\"Error:incorrect job id received, %u [expected %u]\\n\", id, id_count);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\trte_pktmbuf_free(src);\n+\t\trte_pktmbuf_free(dst);\n+\n+\t\t/* now check completion works */\n+\t\tif (rte_dmadev_completed(dev_id, 0, 1, NULL, NULL) != 0) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_completed in empty check\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tid_count++;\n+\n+\t} while (0);\n+\n+\t/* test doing a multiple single copies */\n+\tdo {\n+\t\tconst uint16_t max_ops = 4;\n+\t\tstruct rte_mbuf *src, *dst;\n+\t\tchar *src_data, *dst_data;\n+\n+\t\tsrc = rte_pktmbuf_alloc(pool);\n+\t\tdst = rte_pktmbuf_alloc(pool);\n+\t\tsrc_data = rte_pktmbuf_mtod(src, char *);\n+\t\tdst_data = rte_pktmbuf_mtod(dst, char *);\n+\n+\t\tfor (i = 0; i < COPY_LEN; i++)\n+\t\t\tsrc_data[i] = rand() & 0xFF;\n+\n+\t\t/* perform the same copy <max_ops> times */\n+\t\tfor (i = 0; i < max_ops; i++) {\n+\t\t\tif (rte_dmadev_copy(dev_id, 0,\n+\t\t\t\t\tsrc->buf_iova + src->data_off,\n+\t\t\t\t\tdst->buf_iova + dst->data_off,\n+\t\t\t\t\tCOPY_LEN, 0) != id_count++) {\n+\t\t\t\tPRINT_ERR(\"Error with rte_dmadev_copy\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\trte_dmadev_perform(dev_id, 0);\n+\t\t}\n+\t\tusleep(10);\n+\n+\t\tif ((i = rte_dmadev_completed(dev_id, 0, max_ops * 2, &id, NULL)) != max_ops) {\n+\t\t\tPRINT_ERR(\"Error with rte_dmadev_completed, got %u not %u\\n\", i, max_ops);\n+\t\t\treturn -1;\n+\t\t}\n+\t\tif (id != id_count - 1) {\n+\t\t\tPRINT_ERR(\"Error, incorrect job id returned: got %u not %u\\n\", id, id_count - 1);\n+\t\t\treturn -1;\n+\t\t}\n+\t\tfor (i = 0; i < COPY_LEN; i++) {\n+\t\t\tif (dst_data[i] != src_data[i]) {\n+\t\t\t\tPRINT_ERR(\"Data mismatch at char %u\\n\", i);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t}\n+\t\trte_pktmbuf_free(src);\n+\t\trte_pktmbuf_free(dst);\n+\t} while (0);\n+\n+\t/* test doing multiple copies */\n+\treturn do_multi_copies(dev_id, 0, 0) /* enqueue and complete one batch at a time */\n+\t\t\t|| do_multi_copies(dev_id, 1, 0) /* enqueue 2 batches and then complete both */\n+\t\t\t|| do_multi_copies(dev_id, 0, 1); /* enqueue 1 batch, then complete in two halves */\n+}\n+\n+static int\n+test_dmadev_instance(uint16_t dev_id)\n+{\n+#define TEST_RINGSIZE 512\n+\tstruct rte_dmadev_info info;\n+\tstruct rte_dmadev_conf conf = { .nb_hw_queues = 1};\n+\tstruct rte_dmadev_queue_conf qconf = { .nb_desc = TEST_RINGSIZE };\n+\tint i;\n+\n+\trte_dmadev_info_get(dev_id, &info);\n+\tif (info.max_hw_queues < 1) {\n+\t\tPRINT_ERR(\"Error, no queues reported on device id %u\\n\", dev_id);\n+\t\treturn -1;\n+\t}\n+\tif (rte_dmadev_configure(dev_id, &conf) != 0) {\n+\t\tPRINT_ERR(\"Error with rte_rawdev_configure()\\n\");\n+\t\treturn -1;\n+\t}\n+\tif (rte_dmadev_queue_setup(dev_id, &qconf) != 0) {\n+\t\tPRINT_ERR(\"Error with queue configuration\\n\");\n+\t\treturn -1;\n+\t}\n+\trte_dmadev_info_get(dev_id, &info);\n+\tif (info.nb_hw_queues != 1) {\n+\t\tPRINT_ERR(\"Error, no configured queues reported on device id %u\\n\", dev_id);\n+\t\treturn -1;\n+\t}\n+\n+\tif (rte_dmadev_start(dev_id) != 0) {\n+\t\tPRINT_ERR(\"Error with rte_rawdev_start()\\n\");\n+\t\treturn -1;\n+\t}\n+\tid_count = 0;\n+\n+\t/* create a mempool for running tests */\n+\tpool = rte_pktmbuf_pool_create(\"TEST_DMADEV_POOL\",\n+\t\t\tTEST_RINGSIZE * 2, /* n == num elements */\n+\t\t\t32,  /* cache size */\n+\t\t\t0,   /* priv size */\n+\t\t\t2048, /* data room size */\n+\t\t\tinfo.socket_id);\n+\tif (pool == NULL) {\n+\t\tPRINT_ERR(\"Error with mempool creation\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* run the test cases */\n+\tprintf(\"DMA Dev: %u, Running Copy Tests\\n\", dev_id);\n+\tfor (i = 0; i < 768; i++) {\n+\t\tstruct rte_dmadev_stats stats;\n+\n+\t\tif (test_enqueue_copies(dev_id) != 0) {\n+\t\t\tprintf(\"Error with iteration %d\\n\", i);\n+\t\t\trte_dmadev_dump(dev_id, stdout);\n+\t\t\tgoto err;\n+\t\t}\n+\n+\t\trte_dmadev_stats_get(dev_id, 0, &stats);\n+\t\tprintf(\"Ops enqueued: %\"PRIu64\"\\t\", stats.enqueued_count);\n+\t\tprintf(\"Ops completed: %\"PRIu64\"\\r\", stats.completed_count);\n+\t}\n+\tprintf(\"\\n\");\n+\n+\trte_mempool_free(pool);\n+\trte_dmadev_stop(dev_id);\n+\n+\treturn 0;\n+\n+err:\n+\trte_mempool_free(pool);\n+\trte_dmadev_stop(dev_id);\n+\treturn -1;\n+}\n+\n+static int\n+test_dmadevs(void)\n+{\n+\tint i;\n+\n+\tif (rte_dmadev_count() == 0)\n+\t\treturn TEST_SKIPPED;\n+\n+\tfor (i = 0; i < RTE_DMADEV_MAX_DEVS; i++)\n+\t\tif (rte_dmadevices[i].attached && test_dmadev_instance(i) < 0)\n+\t\t\treturn -1;\n+\treturn 0;\n+}\n+\n+REGISTER_TEST_COMMAND(dmadev_autotest, test_dmadevs);\n",
    "prefixes": [
        "RFC",
        "UPDATE",
        "9/9"
    ]
}