get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 61491,
    "url": "http://patchwork.dpdk.org/api/patches/61491/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20191021002300.26497-4-honnappa.nagarahalli@arm.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": "<20191021002300.26497-4-honnappa.nagarahalli@arm.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20191021002300.26497-4-honnappa.nagarahalli@arm.com",
    "date": "2019-10-21T00:22:57",
    "name": "[RFC,v6,3/6] test/ring: add functional tests for configurable element size ring",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "e8c88ce4aa99366c92880bfd81fd292e3676c1ae",
    "submitter": {
        "id": 1045,
        "url": "http://patchwork.dpdk.org/api/people/1045/?format=api",
        "name": "Honnappa Nagarahalli",
        "email": "honnappa.nagarahalli@arm.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patchwork.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20191021002300.26497-4-honnappa.nagarahalli@arm.com/mbox/",
    "series": [
        {
            "id": 6949,
            "url": "http://patchwork.dpdk.org/api/series/6949/?format=api",
            "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=6949",
            "date": "2019-10-21T00:22:54",
            "name": "lib/ring: APIs to support custom element size",
            "version": 6,
            "mbox": "http://patchwork.dpdk.org/series/6949/mbox/"
        }
    ],
    "comments": "http://patchwork.dpdk.org/api/patches/61491/comments/",
    "check": "warning",
    "checks": "http://patchwork.dpdk.org/api/patches/61491/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<dev-bounces@dpdk.org>",
        "X-Original-To": "patchwork@dpdk.org",
        "Delivered-To": "patchwork@dpdk.org",
        "Received": [
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 2B31C2986;\n\tMon, 21 Oct 2019 02:23:47 +0200 (CEST)",
            "from foss.arm.com (unknown [217.140.110.172])\n\tby dpdk.org (Postfix) with ESMTP id 0A1721252\n\tfor <dev@dpdk.org>; Mon, 21 Oct 2019 02:23:41 +0200 (CEST)",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n\tby usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 68930495;\n\tSun, 20 Oct 2019 17:23:33 -0700 (PDT)",
            "from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com\n\t[10.118.12.34])\n\tby usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id\n\t4B71B3F71F; Sun, 20 Oct 2019 17:23:33 -0700 (PDT)"
        ],
        "From": "Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>",
        "To": "olivier.matz@6wind.com, sthemmin@microsoft.com, jerinj@marvell.com,\n\tbruce.richardson@intel.com, david.marchand@redhat.com,\n\tpbhagavatula@marvell.com, konstantin.ananyev@intel.com,\n\tdrc@linux.vnet.ibm.com, hemant.agrawal@nxp.com,\n\thonnappa.nagarahalli@arm.com",
        "Cc": "dev@dpdk.org, dharmik.thakkar@arm.com, ruifeng.wang@arm.com,\n\tgavin.hu@arm.com",
        "Date": "Sun, 20 Oct 2019 19:22:57 -0500",
        "Message-Id": "<20191021002300.26497-4-honnappa.nagarahalli@arm.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20191021002300.26497-1-honnappa.nagarahalli@arm.com>",
        "References": "<20190906190510.11146-1-honnappa.nagarahalli@arm.com>\n\t<20191021002300.26497-1-honnappa.nagarahalli@arm.com>",
        "Subject": "[dpdk-dev] [RFC v6 3/6] test/ring: add functional tests for\n\tconfigurable element size ring",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<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\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Add functional tests for rte_ring_xxx_elem APIs. At this point these\nare derived mainly from existing rte_ring_xxx test cases.\n\nSigned-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>\n---\n app/test/Makefile         |   1 +\n app/test/meson.build      |   1 +\n app/test/test_ring_elem.c | 859 ++++++++++++++++++++++++++++++++++++++\n 3 files changed, 861 insertions(+)\n create mode 100644 app/test/test_ring_elem.c",
    "diff": "diff --git a/app/test/Makefile b/app/test/Makefile\nindex 26ba6fe2b..483865b4a 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -77,6 +77,7 @@ SRCS-y += test_external_mem.c\n SRCS-y += test_rand_perf.c\n \n SRCS-y += test_ring.c\n+SRCS-y += test_ring_elem.c\n SRCS-y += test_ring_perf.c\n SRCS-y += test_pmd_perf.c\n \ndiff --git a/app/test/meson.build b/app/test/meson.build\nindex ec40943bd..1ca25c00a 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -100,6 +100,7 @@ test_sources = files('commands.c',\n \t'test_red.c',\n \t'test_reorder.c',\n \t'test_ring.c',\n+\t'test_ring_elem.c',\n \t'test_ring_perf.c',\n \t'test_rwlock.c',\n \t'test_sched.c',\ndiff --git a/app/test/test_ring_elem.c b/app/test/test_ring_elem.c\nnew file mode 100644\nindex 000000000..54ae35a71\n--- /dev/null\n+++ b/app/test/test_ring_elem.c\n@@ -0,0 +1,859 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2010-2014 Intel Corporation\n+ */\n+\n+#include <string.h>\n+#include <stdarg.h>\n+#include <stdio.h>\n+#include <stdlib.h>\n+#include <stdint.h>\n+#include <inttypes.h>\n+#include <errno.h>\n+#include <sys/queue.h>\n+\n+#include <rte_common.h>\n+#include <rte_log.h>\n+#include <rte_memory.h>\n+#include <rte_launch.h>\n+#include <rte_cycles.h>\n+#include <rte_eal.h>\n+#include <rte_per_lcore.h>\n+#include <rte_lcore.h>\n+#include <rte_atomic.h>\n+#include <rte_branch_prediction.h>\n+#include <rte_malloc.h>\n+#include <rte_ring.h>\n+#include <rte_ring_elem.h>\n+#include <rte_random.h>\n+#include <rte_errno.h>\n+#include <rte_hexdump.h>\n+\n+#include \"test.h\"\n+\n+/*\n+ * Ring\n+ * ====\n+ *\n+ * #. Basic tests: done on one core:\n+ *\n+ *    - Using single producer/single consumer functions:\n+ *\n+ *      - Enqueue one object, two objects, MAX_BULK objects\n+ *      - Dequeue one object, two objects, MAX_BULK objects\n+ *      - Check that dequeued pointers are correct\n+ *\n+ *    - Using multi producers/multi consumers functions:\n+ *\n+ *      - Enqueue one object, two objects, MAX_BULK objects\n+ *      - Dequeue one object, two objects, MAX_BULK objects\n+ *      - Check that dequeued pointers are correct\n+ *\n+ * #. Performance tests.\n+ *\n+ * Tests done in test_ring_perf.c\n+ */\n+\n+#define RING_SIZE 4096\n+#define MAX_BULK 32\n+\n+static rte_atomic32_t synchro;\n+\n+#define\tTEST_RING_VERIFY(exp)\t\t\t\t\t\t\\\n+\tif (!(exp)) {\t\t\t\t\t\t\t\\\n+\t\tprintf(\"error at %s:%d\\tcondition \" #exp \" failed\\n\",\t\\\n+\t\t    __func__, __LINE__);\t\t\t\t\\\n+\t\trte_ring_dump(stdout, r);\t\t\t\t\\\n+\t\treturn -1;\t\t\t\t\t\t\\\n+\t}\n+\n+#define\tTEST_RING_FULL_EMTPY_ITER\t8\n+\n+/*\n+ * helper routine for test_ring_basic\n+ */\n+static int\n+test_ring_basic_full_empty(struct rte_ring *r, void * const src, void *dst)\n+{\n+\tunsigned i, rand;\n+\tconst unsigned rsz = RING_SIZE - 1;\n+\n+\tprintf(\"Basic full/empty test\\n\");\n+\n+\tfor (i = 0; TEST_RING_FULL_EMTPY_ITER != i; i++) {\n+\n+\t\t/* random shift in the ring */\n+\t\trand = RTE_MAX(rte_rand() % RING_SIZE, 1UL);\n+\t\tprintf(\"%s: iteration %u, random shift: %u;\\n\",\n+\t\t    __func__, i, rand);\n+\t\tTEST_RING_VERIFY(rte_ring_enqueue_bulk_elem(r, src, 8, rand,\n+\t\t\t\tNULL) != 0);\n+\t\tTEST_RING_VERIFY(rte_ring_dequeue_bulk_elem(r, dst, 8, rand,\n+\t\t\t\tNULL) == rand);\n+\n+\t\t/* fill the ring */\n+\t\tTEST_RING_VERIFY(rte_ring_enqueue_bulk_elem(r, src, 8, rsz, NULL) != 0);\n+\t\tTEST_RING_VERIFY(0 == rte_ring_free_count(r));\n+\t\tTEST_RING_VERIFY(rsz == rte_ring_count(r));\n+\t\tTEST_RING_VERIFY(rte_ring_full(r));\n+\t\tTEST_RING_VERIFY(0 == rte_ring_empty(r));\n+\n+\t\t/* empty the ring */\n+\t\tTEST_RING_VERIFY(rte_ring_dequeue_bulk_elem(r, dst, 8, rsz,\n+\t\t\t\tNULL) == rsz);\n+\t\tTEST_RING_VERIFY(rsz == rte_ring_free_count(r));\n+\t\tTEST_RING_VERIFY(0 == rte_ring_count(r));\n+\t\tTEST_RING_VERIFY(0 == rte_ring_full(r));\n+\t\tTEST_RING_VERIFY(rte_ring_empty(r));\n+\n+\t\t/* check data */\n+\t\tTEST_RING_VERIFY(0 == memcmp(src, dst, rsz));\n+\t\trte_ring_dump(stdout, r);\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+test_ring_basic(struct rte_ring *r)\n+{\n+\tvoid **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;\n+\tint ret;\n+\tunsigned i, num_elems;\n+\n+\t/* alloc dummy object pointers */\n+\tsrc = malloc(RING_SIZE*2*sizeof(void *));\n+\tif (src == NULL)\n+\t\tgoto fail;\n+\n+\tfor (i = 0; i < RING_SIZE*2 ; i++) {\n+\t\tsrc[i] = (void *)(unsigned long)i;\n+\t}\n+\tcur_src = src;\n+\n+\t/* alloc some room for copied objects */\n+\tdst = malloc(RING_SIZE*2*sizeof(void *));\n+\tif (dst == NULL)\n+\t\tgoto fail;\n+\n+\tmemset(dst, 0, RING_SIZE*2*sizeof(void *));\n+\tcur_dst = dst;\n+\n+\tprintf(\"enqueue 1 obj\\n\");\n+\tret = rte_ring_sp_enqueue_bulk_elem(r, cur_src, 8, 1, NULL);\n+\tcur_src += 1;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue 2 objs\\n\");\n+\tret = rte_ring_sp_enqueue_bulk_elem(r, cur_src, 8, 2, NULL);\n+\tcur_src += 2;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue MAX_BULK objs\\n\");\n+\tret = rte_ring_sp_enqueue_bulk_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\tcur_src += MAX_BULK;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 1 obj\\n\");\n+\tret = rte_ring_sc_dequeue_bulk_elem(r, cur_dst, 8, 1, NULL);\n+\tcur_dst += 1;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 2 objs\\n\");\n+\tret = rte_ring_sc_dequeue_bulk_elem(r, cur_dst, 8, 2, NULL);\n+\tcur_dst += 2;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue MAX_BULK objs\\n\");\n+\tret = rte_ring_sc_dequeue_bulk_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\tcur_dst += MAX_BULK;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"enqueue 1 obj\\n\");\n+\tret = rte_ring_mp_enqueue_bulk_elem(r, cur_src, 8, 1, NULL);\n+\tcur_src += 1;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue 2 objs\\n\");\n+\tret = rte_ring_mp_enqueue_bulk_elem(r, cur_src, 8, 2, NULL);\n+\tcur_src += 2;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue MAX_BULK objs\\n\");\n+\tret = rte_ring_mp_enqueue_bulk_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\tcur_src += MAX_BULK;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 1 obj\\n\");\n+\tret = rte_ring_mc_dequeue_bulk_elem(r, cur_dst, 8, 1, NULL);\n+\tcur_dst += 1;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 2 objs\\n\");\n+\tret = rte_ring_mc_dequeue_bulk_elem(r, cur_dst, 8, 2, NULL);\n+\tcur_dst += 2;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue MAX_BULK objs\\n\");\n+\tret = rte_ring_mc_dequeue_bulk_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\tcur_dst += MAX_BULK;\n+\tif (ret == 0)\n+\t\tgoto fail;\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"fill and empty the ring\\n\");\n+\tfor (i = 0; i<RING_SIZE/MAX_BULK; i++) {\n+\t\tret = rte_ring_mp_enqueue_bulk_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\t\tcur_src += MAX_BULK;\n+\t\tif (ret == 0)\n+\t\t\tgoto fail;\n+\t\tret = rte_ring_mc_dequeue_bulk_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\t\tcur_dst += MAX_BULK;\n+\t\tif (ret == 0)\n+\t\t\tgoto fail;\n+\t}\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\tif (test_ring_basic_full_empty(r, src, dst) != 0)\n+\t\tgoto fail;\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"test default bulk enqueue / dequeue\\n\");\n+\tnum_elems = 16;\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tret = rte_ring_enqueue_bulk_elem(r, cur_src, 8, num_elems, NULL);\n+\tcur_src += num_elems;\n+\tif (ret == 0) {\n+\t\tprintf(\"Cannot enqueue\\n\");\n+\t\tgoto fail;\n+\t}\n+\tret = rte_ring_enqueue_bulk_elem(r, cur_src, 8, num_elems, NULL);\n+\tcur_src += num_elems;\n+\tif (ret == 0) {\n+\t\tprintf(\"Cannot enqueue\\n\");\n+\t\tgoto fail;\n+\t}\n+\tret = rte_ring_dequeue_bulk_elem(r, cur_dst, 8, num_elems, NULL);\n+\tcur_dst += num_elems;\n+\tif (ret == 0) {\n+\t\tprintf(\"Cannot dequeue\\n\");\n+\t\tgoto fail;\n+\t}\n+\tret = rte_ring_dequeue_bulk_elem(r, cur_dst, 8, num_elems, NULL);\n+\tcur_dst += num_elems;\n+\tif (ret == 0) {\n+\t\tprintf(\"Cannot dequeue2\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tret = rte_ring_mp_enqueue_elem(r, cur_src, 8);\n+\tif (ret != 0)\n+\t\tgoto fail;\n+\n+\tret = rte_ring_mc_dequeue_elem(r, cur_dst, 8);\n+\tif (ret != 0)\n+\t\tgoto fail;\n+\n+\tfree(src);\n+\tfree(dst);\n+\treturn 0;\n+\n+ fail:\n+\tfree(src);\n+\tfree(dst);\n+\treturn -1;\n+}\n+\n+static int\n+test_ring_burst_basic(struct rte_ring *r)\n+{\n+\tvoid **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL;\n+\tint ret;\n+\tunsigned i;\n+\n+\t/* alloc dummy object pointers */\n+\tsrc = malloc(RING_SIZE*2*sizeof(void *));\n+\tif (src == NULL)\n+\t\tgoto fail;\n+\n+\tfor (i = 0; i < RING_SIZE*2 ; i++) {\n+\t\tsrc[i] = (void *)(unsigned long)i;\n+\t}\n+\tcur_src = src;\n+\n+\t/* alloc some room for copied objects */\n+\tdst = malloc(RING_SIZE*2*sizeof(void *));\n+\tif (dst == NULL)\n+\t\tgoto fail;\n+\n+\tmemset(dst, 0, RING_SIZE*2*sizeof(void *));\n+\tcur_dst = dst;\n+\n+\tprintf(\"Test SP & SC basic functions \\n\");\n+\tprintf(\"enqueue 1 obj\\n\");\n+\tret = rte_ring_sp_enqueue_burst_elem(r, cur_src, 8, 1, NULL);\n+\tcur_src += 1;\n+\tif (ret != 1)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue 2 objs\\n\");\n+\tret = rte_ring_sp_enqueue_burst_elem(r, cur_src, 8, 2, NULL);\n+\tcur_src += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue MAX_BULK objs\\n\");\n+\tret = rte_ring_sp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\tcur_src += MAX_BULK;\n+\tif (ret != MAX_BULK)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 1 obj\\n\");\n+\tret = rte_ring_sc_dequeue_burst_elem(r, cur_dst, 8, 1, NULL);\n+\tcur_dst += 1;\n+\tif (ret != 1)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 2 objs\\n\");\n+\tret = rte_ring_sc_dequeue_burst_elem(r, cur_dst, 8, 2, NULL);\n+\tcur_dst += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue MAX_BULK objs\\n\");\n+\tret = rte_ring_sc_dequeue_burst_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\tcur_dst += MAX_BULK;\n+\tif (ret != MAX_BULK)\n+\t\tgoto fail;\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"Test enqueue without enough memory space \\n\");\n+\tfor (i = 0; i < (RING_SIZE/MAX_BULK - 1); i++) {\n+\t\tret = rte_ring_sp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\t\tcur_src += MAX_BULK;\n+\t\tif (ret != MAX_BULK)\n+\t\t\tgoto fail;\n+\t}\n+\n+\tprintf(\"Enqueue 2 objects, free entries = MAX_BULK - 2  \\n\");\n+\tret = rte_ring_sp_enqueue_burst_elem(r, cur_src, 8, 2, NULL);\n+\tcur_src += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tprintf(\"Enqueue the remaining entries = MAX_BULK - 2  \\n\");\n+\t/* Always one free entry left */\n+\tret = rte_ring_sp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\tcur_src += MAX_BULK - 3;\n+\tif (ret != MAX_BULK - 3)\n+\t\tgoto fail;\n+\n+\tprintf(\"Test if ring is full  \\n\");\n+\tif (rte_ring_full(r) != 1)\n+\t\tgoto fail;\n+\n+\tprintf(\"Test enqueue for a full entry  \\n\");\n+\tret = rte_ring_sp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\tif (ret != 0)\n+\t\tgoto fail;\n+\n+\tprintf(\"Test dequeue without enough objects \\n\");\n+\tfor (i = 0; i<RING_SIZE/MAX_BULK - 1; i++) {\n+\t\tret = rte_ring_sc_dequeue_burst_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\t\tcur_dst += MAX_BULK;\n+\t\tif (ret != MAX_BULK)\n+\t\t\tgoto fail;\n+\t}\n+\n+\t/* Available memory space for the exact MAX_BULK entries */\n+\tret = rte_ring_sc_dequeue_burst_elem(r, cur_dst, 8, 2, NULL);\n+\tcur_dst += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tret = rte_ring_sc_dequeue_burst_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\tcur_dst += MAX_BULK - 3;\n+\tif (ret != MAX_BULK - 3)\n+\t\tgoto fail;\n+\n+\tprintf(\"Test if ring is empty \\n\");\n+\t/* Check if ring is empty */\n+\tif (1 != rte_ring_empty(r))\n+\t\tgoto fail;\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"Test MP & MC basic functions \\n\");\n+\n+\tprintf(\"enqueue 1 obj\\n\");\n+\tret = rte_ring_mp_enqueue_burst_elem(r, cur_src, 8, 1, NULL);\n+\tcur_src += 1;\n+\tif (ret != 1)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue 2 objs\\n\");\n+\tret = rte_ring_mp_enqueue_burst_elem(r, cur_src, 8, 2, NULL);\n+\tcur_src += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tprintf(\"enqueue MAX_BULK objs\\n\");\n+\tret = rte_ring_mp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\tcur_src += MAX_BULK;\n+\tif (ret != MAX_BULK)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 1 obj\\n\");\n+\tret = rte_ring_mc_dequeue_burst_elem(r, cur_dst, 8, 1, NULL);\n+\tcur_dst += 1;\n+\tif (ret != 1)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue 2 objs\\n\");\n+\tret = rte_ring_mc_dequeue_burst_elem(r, cur_dst, 8, 2, NULL);\n+\tcur_dst += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tprintf(\"dequeue MAX_BULK objs\\n\");\n+\tret = rte_ring_mc_dequeue_burst_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\tcur_dst += MAX_BULK;\n+\tif (ret != MAX_BULK)\n+\t\tgoto fail;\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"fill and empty the ring\\n\");\n+\tfor (i = 0; i < RING_SIZE/MAX_BULK; i++) {\n+\t\tret = rte_ring_mp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\t\tcur_src += MAX_BULK;\n+\t\tif (ret != MAX_BULK)\n+\t\t\tgoto fail;\n+\t\tret = rte_ring_mc_dequeue_burst_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\t\tcur_dst += MAX_BULK;\n+\t\tif (ret != MAX_BULK)\n+\t\t\tgoto fail;\n+\t}\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"Test enqueue without enough memory space \\n\");\n+\tfor (i = 0; i < RING_SIZE/MAX_BULK - 1; i++) {\n+\t\tret = rte_ring_mp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\t\tcur_src += MAX_BULK;\n+\t\tif (ret != MAX_BULK)\n+\t\t\tgoto fail;\n+\t}\n+\n+\t/* Available memory space for the exact MAX_BULK objects */\n+\tret = rte_ring_mp_enqueue_burst_elem(r, cur_src, 8, 2, NULL);\n+\tcur_src += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tret = rte_ring_mp_enqueue_burst_elem(r, cur_src, 8, MAX_BULK, NULL);\n+\tcur_src += MAX_BULK - 3;\n+\tif (ret != MAX_BULK - 3)\n+\t\tgoto fail;\n+\n+\n+\tprintf(\"Test dequeue without enough objects \\n\");\n+\tfor (i = 0; i < RING_SIZE/MAX_BULK - 1; i++) {\n+\t\tret = rte_ring_mc_dequeue_burst_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\t\tcur_dst += MAX_BULK;\n+\t\tif (ret != MAX_BULK)\n+\t\t\tgoto fail;\n+\t}\n+\n+\t/* Available objects - the exact MAX_BULK */\n+\tret = rte_ring_mc_dequeue_burst_elem(r, cur_dst, 8, 2, NULL);\n+\tcur_dst += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tret = rte_ring_mc_dequeue_burst_elem(r, cur_dst, 8, MAX_BULK, NULL);\n+\tcur_dst += MAX_BULK - 3;\n+\tif (ret != MAX_BULK - 3)\n+\t\tgoto fail;\n+\n+\t/* check data */\n+\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\tgoto fail;\n+\t}\n+\n+\tcur_src = src;\n+\tcur_dst = dst;\n+\n+\tprintf(\"Covering rte_ring_enqueue_burst functions \\n\");\n+\n+\tret = rte_ring_enqueue_burst_elem(r, cur_src, 8, 2, NULL);\n+\tcur_src += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\tret = rte_ring_dequeue_burst_elem(r, cur_dst, 8, 2, NULL);\n+\tcur_dst += 2;\n+\tif (ret != 2)\n+\t\tgoto fail;\n+\n+\t/* Free memory before test completed */\n+\tfree(src);\n+\tfree(dst);\n+\treturn 0;\n+\n+ fail:\n+\tfree(src);\n+\tfree(dst);\n+\treturn -1;\n+}\n+\n+/*\n+ * it will always fail to create ring with a wrong ring size number in this function\n+ */\n+static int\n+test_ring_creation_with_wrong_size(void)\n+{\n+\tstruct rte_ring * rp = NULL;\n+\n+\t/* Test if ring size is not power of 2 */\n+\trp = rte_ring_create_elem(\"test_bad_ring_size\", RING_SIZE + 1, 8, SOCKET_ID_ANY, 0);\n+\tif (NULL != rp) {\n+\t\treturn -1;\n+\t}\n+\n+\t/* Test if ring size is exceeding the limit */\n+\trp = rte_ring_create_elem(\"test_bad_ring_size\", (RTE_RING_SZ_MASK + 1), 8, SOCKET_ID_ANY, 0);\n+\tif (NULL != rp) {\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+ * it tests if it would always fail to create ring with an used ring name\n+ */\n+static int\n+test_ring_creation_with_an_used_name(void)\n+{\n+\tstruct rte_ring * rp;\n+\n+\trp = rte_ring_create_elem(\"test\", RING_SIZE, 8, SOCKET_ID_ANY, 0);\n+\tif (NULL != rp)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+/*\n+ * Test to if a non-power of 2 count causes the create\n+ * function to fail correctly\n+ */\n+static int\n+test_create_count_odd(void)\n+{\n+\tstruct rte_ring *r = rte_ring_create_elem(\"test_ring_count\",\n+\t\t\t4097, 8, SOCKET_ID_ANY, 0 );\n+\tif(r != NULL){\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+/*\n+ * it tests some more basic ring operations\n+ */\n+static int\n+test_ring_basic_ex(void)\n+{\n+\tint ret = -1;\n+\tunsigned i;\n+\tstruct rte_ring *rp = NULL;\n+\tvoid **obj = NULL;\n+\n+\tobj = rte_calloc(\"test_ring_basic_ex_malloc\", RING_SIZE, sizeof(void *), 0);\n+\tif (obj == NULL) {\n+\t\tprintf(\"test_ring_basic_ex fail to rte_malloc\\n\");\n+\t\tgoto fail_test;\n+\t}\n+\n+\trp = rte_ring_create_elem(\"test_ring_basic_ex\", RING_SIZE, 8, SOCKET_ID_ANY,\n+\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ);\n+\tif (rp == NULL) {\n+\t\tprintf(\"test_ring_basic_ex fail to create ring\\n\");\n+\t\tgoto fail_test;\n+\t}\n+\n+\tif (rte_ring_lookup(\"test_ring_basic_ex\") != rp) {\n+\t\tgoto fail_test;\n+\t}\n+\n+\tif (rte_ring_empty(rp) != 1) {\n+\t\tprintf(\"test_ring_basic_ex ring is not empty but it should be\\n\");\n+\t\tgoto fail_test;\n+\t}\n+\n+\tprintf(\"%u ring entries are now free\\n\", rte_ring_free_count(rp));\n+\n+\tfor (i = 0; i < RING_SIZE; i ++) {\n+\t\trte_ring_enqueue_elem(rp, &obj[i], 8);\n+\t}\n+\n+\tif (rte_ring_full(rp) != 1) {\n+\t\tprintf(\"test_ring_basic_ex ring is not full but it should be\\n\");\n+\t\tgoto fail_test;\n+\t}\n+\n+\tfor (i = 0; i < RING_SIZE; i ++) {\n+\t\trte_ring_dequeue_elem(rp, &obj[i], 8);\n+\t}\n+\n+\tif (rte_ring_empty(rp) != 1) {\n+\t\tprintf(\"test_ring_basic_ex ring is not empty but it should be\\n\");\n+\t\tgoto fail_test;\n+\t}\n+\n+\t/* Covering the ring burst operation */\n+\tret = rte_ring_enqueue_burst_elem(rp, obj, 8, 2, NULL);\n+\tif (ret != 2) {\n+\t\tprintf(\"test_ring_basic_ex: rte_ring_enqueue_burst fails \\n\");\n+\t\tgoto fail_test;\n+\t}\n+\n+\tret = rte_ring_dequeue_burst_elem(rp, obj, 8, 2, NULL);\n+\tif (ret != 2) {\n+\t\tprintf(\"test_ring_basic_ex: rte_ring_dequeue_burst fails \\n\");\n+\t\tgoto fail_test;\n+\t}\n+\n+\tret = 0;\n+fail_test:\n+\trte_ring_free(rp);\n+\tif (obj != NULL)\n+\t\trte_free(obj);\n+\n+\treturn ret;\n+}\n+\n+static int\n+test_ring_with_exact_size(void)\n+{\n+\tstruct rte_ring *std_ring = NULL, *exact_sz_ring = NULL;\n+\tvoid *ptr_array[16];\n+\tstatic const unsigned int ring_sz = RTE_DIM(ptr_array);\n+\tunsigned int i;\n+\tint ret = -1;\n+\n+\tstd_ring = rte_ring_create_elem(\"std\", ring_sz, 8, rte_socket_id(),\n+\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ);\n+\tif (std_ring == NULL) {\n+\t\tprintf(\"%s: error, can't create std ring\\n\", __func__);\n+\t\tgoto end;\n+\t}\n+\texact_sz_ring = rte_ring_create_elem(\"exact sz\", ring_sz, 8, rte_socket_id(),\n+\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ | RING_F_EXACT_SZ);\n+\tif (exact_sz_ring == NULL) {\n+\t\tprintf(\"%s: error, can't create exact size ring\\n\", __func__);\n+\t\tgoto end;\n+\t}\n+\n+\t/*\n+\t * Check that the exact size ring is bigger than the standard ring\n+\t */\n+\tif (rte_ring_get_size(std_ring) >= rte_ring_get_size(exact_sz_ring)) {\n+\t\tprintf(\"%s: error, std ring (size: %u) is not smaller than exact size one (size %u)\\n\",\n+\t\t\t\t__func__,\n+\t\t\t\trte_ring_get_size(std_ring),\n+\t\t\t\trte_ring_get_size(exact_sz_ring));\n+\t\tgoto end;\n+\t}\n+\t/*\n+\t * check that the exact_sz_ring can hold one more element than the\n+\t * standard ring. (16 vs 15 elements)\n+\t */\n+\tfor (i = 0; i < ring_sz - 1; i++) {\n+\t\trte_ring_enqueue_elem(std_ring, ptr_array, 8);\n+\t\trte_ring_enqueue_elem(exact_sz_ring, ptr_array, 8);\n+\t}\n+\tif (rte_ring_enqueue_elem(std_ring, ptr_array, 8) != -ENOBUFS) {\n+\t\tprintf(\"%s: error, unexpected successful enqueue\\n\", __func__);\n+\t\tgoto end;\n+\t}\n+\tif (rte_ring_enqueue_elem(exact_sz_ring, ptr_array, 8) == -ENOBUFS) {\n+\t\tprintf(\"%s: error, enqueue failed\\n\", __func__);\n+\t\tgoto end;\n+\t}\n+\n+\t/* check that dequeue returns the expected number of elements */\n+\tif (rte_ring_dequeue_burst_elem(exact_sz_ring, ptr_array, 8,\n+\t\t\tRTE_DIM(ptr_array), NULL) != ring_sz) {\n+\t\tprintf(\"%s: error, failed to dequeue expected nb of elements\\n\",\n+\t\t\t\t__func__);\n+\t\tgoto end;\n+\t}\n+\n+\t/* check that the capacity function returns expected value */\n+\tif (rte_ring_get_capacity(exact_sz_ring) != ring_sz) {\n+\t\tprintf(\"%s: error, incorrect ring capacity reported\\n\",\n+\t\t\t\t__func__);\n+\t\tgoto end;\n+\t}\n+\n+\tret = 0; /* all ok if we get here */\n+end:\n+\trte_ring_free(std_ring);\n+\trte_ring_free(exact_sz_ring);\n+\treturn ret;\n+}\n+\n+static int\n+test_ring(void)\n+{\n+\tstruct rte_ring *r = NULL;\n+\n+\t/* some more basic operations */\n+\tif (test_ring_basic_ex() < 0)\n+\t\tgoto test_fail;\n+\n+\trte_atomic32_init(&synchro);\n+\n+\tr = rte_ring_create_elem(\"test\", RING_SIZE, 8, SOCKET_ID_ANY, 0);\n+\tif (r == NULL)\n+\t\tgoto test_fail;\n+\n+\t/* retrieve the ring from its name */\n+\tif (rte_ring_lookup(\"test\") != r) {\n+\t\tprintf(\"Cannot lookup ring from its name\\n\");\n+\t\tgoto test_fail;\n+\t}\n+\n+\t/* burst operations */\n+\tif (test_ring_burst_basic(r) < 0)\n+\t\tgoto test_fail;\n+\n+\t/* basic operations */\n+\tif (test_ring_basic(r) < 0)\n+\t\tgoto test_fail;\n+\n+\t/* basic operations */\n+\tif ( test_create_count_odd() < 0){\n+\t\tprintf(\"Test failed to detect odd count\\n\");\n+\t\tgoto test_fail;\n+\t} else\n+\t\tprintf(\"Test detected odd count\\n\");\n+\n+\t/* test of creating ring with wrong size */\n+\tif (test_ring_creation_with_wrong_size() < 0)\n+\t\tgoto test_fail;\n+\n+\t/* test of creation ring with an used name */\n+\tif (test_ring_creation_with_an_used_name() < 0)\n+\t\tgoto test_fail;\n+\n+\tif (test_ring_with_exact_size() < 0)\n+\t\tgoto test_fail;\n+\n+\t/* dump the ring status */\n+\trte_ring_list_dump(stdout);\n+\n+\trte_ring_free(r);\n+\n+\treturn 0;\n+\n+test_fail:\n+\trte_ring_free(r);\n+\n+\treturn -1;\n+}\n+\n+REGISTER_TEST_COMMAND(ring_elem_autotest, test_ring);\n",
    "prefixes": [
        "RFC",
        "v6",
        "3/6"
    ]
}