get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 64569,
    "url": "http://patches.dpdk.org/api/patches/64569/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200113172518.37815-4-honnappa.nagarahalli@arm.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<20200113172518.37815-4-honnappa.nagarahalli@arm.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200113172518.37815-4-honnappa.nagarahalli@arm.com",
    "date": "2020-01-13T17:25:15",
    "name": "[v8,3/6] test/ring: add functional tests for rte_ring_xxx_elem APIs",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "3187b6a33fea788fc3f44a1122d3b7dc9c95acf6",
    "submitter": {
        "id": 1045,
        "url": "http://patches.dpdk.org/api/people/1045/?format=api",
        "name": "Honnappa Nagarahalli",
        "email": "honnappa.nagarahalli@arm.com"
    },
    "delegate": {
        "id": 24651,
        "url": "http://patches.dpdk.org/api/users/24651/?format=api",
        "username": "dmarchand",
        "first_name": "David",
        "last_name": "Marchand",
        "email": "david.marchand@redhat.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200113172518.37815-4-honnappa.nagarahalli@arm.com/mbox/",
    "series": [
        {
            "id": 8086,
            "url": "http://patches.dpdk.org/api/series/8086/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8086",
            "date": "2020-01-13T17:25:12",
            "name": "lib/ring: APIs to support custom element size",
            "version": 8,
            "mbox": "http://patches.dpdk.org/series/8086/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/64569/comments/",
    "check": "fail",
    "checks": "http://patches.dpdk.org/api/patches/64569/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 dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id B512AA04F1;\n\tMon, 13 Jan 2020 18:26:03 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 95D0A1D17C;\n\tMon, 13 Jan 2020 18:25:46 +0100 (CET)",
            "from foss.arm.com (foss.arm.com [217.140.110.172])\n by dpdk.org (Postfix) with ESMTP id 2F4081D170\n for <dev@dpdk.org>; Mon, 13 Jan 2020 18:25:40 +0100 (CET)",
            "from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14])\n by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AE91B142F;\n Mon, 13 Jan 2020 09:25:39 -0800 (PST)",
            "from qc2400f-1.austin.arm.com (qc2400f-1.austin.arm.com\n [10.118.14.48])\n by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 939BF3F534;\n Mon, 13 Jan 2020 09:25:39 -0800 (PST)"
        ],
        "From": "Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>",
        "To": "olivier.matz@6wind.com, sthemmin@microsoft.com, jerinj@marvell.com,\n bruce.richardson@intel.com, david.marchand@redhat.com,\n pbhagavatula@marvell.com, konstantin.ananyev@intel.com,\n honnappa.nagarahalli@arm.com",
        "Cc": "dev@dpdk.org, dharmik.thakkar@arm.com, ruifeng.wang@arm.com,\n gavin.hu@arm.com, nd@arm.com",
        "Date": "Mon, 13 Jan 2020 11:25:15 -0600",
        "Message-Id": "<20200113172518.37815-4-honnappa.nagarahalli@arm.com>",
        "X-Mailer": "git-send-email 2.17.1",
        "In-Reply-To": "<20200113172518.37815-1-honnappa.nagarahalli@arm.com>",
        "References": "<20190906190510.11146-1-honnappa.nagarahalli@arm.com>\n <20200113172518.37815-1-honnappa.nagarahalli@arm.com>",
        "Subject": "[dpdk-dev] [PATCH v8 3/6] test/ring: add functional tests for\n\trte_ring_xxx_elem APIs",
        "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 <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 basic infrastructure to test rte_ring_xxx_elem APIs.\nAdjust the existing test cases to test for various ring\nelement sizes.\n\nSigned-off-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>\nReviewed-by: Gavin Hu <gavin.hu@arm.com>\n---\n app/test/test_ring.c | 1244 ++++++++++++++++++------------------------\n app/test/test_ring.h |  187 +++++++\n 2 files changed, 722 insertions(+), 709 deletions(-)\n create mode 100644 app/test/test_ring.h",
    "diff": "diff --git a/app/test/test_ring.c b/app/test/test_ring.c\nindex aaf1e70ad..649f65d38 100644\n--- a/app/test/test_ring.c\n+++ b/app/test/test_ring.c\n@@ -23,11 +23,13 @@\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+#include \"test_ring.h\"\n \n /*\n  * Ring\n@@ -55,8 +57,6 @@\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@@ -67,795 +67,624 @@ static rte_atomic32_t synchro;\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(r, src, rand,\n-\t\t\t\tNULL) != 0);\n-\t\tTEST_RING_VERIFY(rte_ring_dequeue_bulk(r, dst, rand,\n-\t\t\t\tNULL) == rand);\n-\n-\t\t/* fill the ring */\n-\t\tTEST_RING_VERIFY(rte_ring_enqueue_bulk(r, src, 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(r, dst, 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+static int esize[] = {-1, 4, 8, 16, 20};\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+static void**\n+test_ring_inc_ptr(void **obj, int esize, unsigned int n)\n+{\n+\t/* Legacy queue APIs? */\n+\tif ((esize) == -1)\n+\t\treturn ((void **)obj) + n;\n+\telse\n+\t\treturn (void **)(((uint32_t *)obj) +\n+\t\t\t\t\t(n * esize / sizeof(uint32_t)));\n }\n \n-static int\n-test_ring_basic(struct rte_ring *r)\n+static void\n+test_ring_mem_init(void *obj, unsigned int count, int esize)\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(r, cur_src, 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(r, cur_src, 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(r, cur_src, 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(r, cur_dst, 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(r, cur_dst, 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(r, cur_dst, 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(r, cur_src, 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(r, cur_src, 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(r, cur_src, 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(r, cur_dst, 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(r, cur_dst, 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(r, cur_dst, 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(r, cur_src, 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(r, cur_dst, 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+\tunsigned int i;\n \n-\tprintf(\"test default bulk enqueue / dequeue\\n\");\n-\tnum_elems = 16;\n+\t/* Legacy queue APIs? */\n+\tif (esize == -1)\n+\t\tfor (i = 0; i < count; i++)\n+\t\t\t((void **)obj)[i] = (void *)(unsigned long)i;\n+\telse\n+\t\tfor (i = 0; i < (count * esize / sizeof(uint32_t)); i++)\n+\t\t\t((uint32_t *)obj)[i] = i;\n+}\n \n-\tcur_src = src;\n-\tcur_dst = dst;\n+static void\n+test_ring_print_test_string(const char *istr, unsigned int api_type, int esize)\n+{\n+\tprintf(\"\\n%s: \", istr);\n+\n+\tif (esize == -1)\n+\t\tprintf(\"legacy APIs: \");\n+\telse\n+\t\tprintf(\"elem APIs: element size %dB \", esize);\n+\n+\tif (api_type == TEST_RING_IGNORE_API_TYPE)\n+\t\treturn;\n+\n+\tif (api_type & TEST_RING_THREAD_DEF)\n+\t\tprintf(\": default enqueue/dequeue: \");\n+\telse if (api_type & TEST_RING_THREAD_SPSC)\n+\t\tprintf(\": SP/SC: \");\n+\telse if (api_type & TEST_RING_THREAD_MPMC)\n+\t\tprintf(\": MP/MC: \");\n+\n+\tif (api_type & TEST_RING_ELEM_SINGLE)\n+\t\tprintf(\"single\\n\");\n+\telse if (api_type & TEST_RING_ELEM_BULK)\n+\t\tprintf(\"bulk\\n\");\n+\telse if (api_type & TEST_RING_ELEM_BURST)\n+\t\tprintf(\"burst\\n\");\n+}\n \n-\tret = rte_ring_enqueue_bulk(r, cur_src, 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(r, cur_src, 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(r, cur_dst, 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(r, cur_dst, 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+ * Various negative test cases.\n+ */\n+static int\n+test_ring_negative_tests(void)\n+{\n+\tstruct rte_ring *rp = NULL;\n+\tstruct rte_ring *rt = NULL;\n+\tunsigned int i;\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/* Test with esize not a multiple of 4 */\n+\trp = test_ring_create(\"test_bad_element_size\", 23,\n+\t\t\t\tRING_SIZE + 1, SOCKET_ID_ANY, 0);\n+\tif (rp != NULL) {\n+\t\tprintf(\"Test failed to detect invalid element size\\n\");\n+\t\tgoto test_fail;\n \t}\n \n-\tcur_src = src;\n-\tcur_dst = dst;\n-\n-\tret = rte_ring_mp_enqueue(r, cur_src);\n-\tif (ret != 0)\n-\t\tgoto fail;\n \n-\tret = rte_ring_mc_dequeue(r, cur_dst);\n-\tif (ret != 0)\n-\t\tgoto fail;\n+\tfor (i = 0; i < RTE_DIM(esize); i++) {\n+\t\t/* Test if ring size is not power of 2 */\n+\t\trp = test_ring_create(\"test_bad_ring_size\", esize[i],\n+\t\t\t\t\tRING_SIZE + 1, SOCKET_ID_ANY, 0);\n+\t\tif (rp != NULL) {\n+\t\t\tprintf(\"Test failed to detect odd count\\n\");\n+\t\t\tgoto test_fail;\n+\t\t}\n+\n+\t\t/* Test if ring size is exceeding the limit */\n+\t\trp = test_ring_create(\"test_bad_ring_size\", esize[i],\n+\t\t\t\t\tRTE_RING_SZ_MASK + 1, SOCKET_ID_ANY, 0);\n+\t\tif (rp != NULL) {\n+\t\t\tprintf(\"Test failed to detect limits\\n\");\n+\t\t\tgoto test_fail;\n+\t\t}\n+\n+\t\t/* Tests if lookup returns NULL on non-existing ring */\n+\t\trp = rte_ring_lookup(\"ring_not_found\");\n+\t\tif (rp != NULL && rte_errno != ENOENT) {\n+\t\t\tprintf(\"Test failed to detect NULL ring lookup\\n\");\n+\t\t\tgoto test_fail;\n+\t\t}\n+\n+\t\t/* Test to if a non-power of 2 count causes the create\n+\t\t * function to fail correctly\n+\t\t */\n+\t\trp = test_ring_create(\"test_ring_count\", esize[i], 4097,\n+\t\t\t\t\tSOCKET_ID_ANY, 0);\n+\t\tif (rp != NULL)\n+\t\t\tgoto test_fail;\n+\n+\t\trp = test_ring_create(\"test_ring_negative\", esize[i], RING_SIZE,\n+\t\t\t\t\tSOCKET_ID_ANY,\n+\t\t\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ);\n+\t\tif (rp == NULL) {\n+\t\t\tprintf(\"test_ring_negative fail to create ring\\n\");\n+\t\t\tgoto test_fail;\n+\t\t}\n+\n+\t\tif (rte_ring_lookup(\"test_ring_negative\") != rp)\n+\t\t\tgoto test_fail;\n+\n+\t\tif (rte_ring_empty(rp) != 1) {\n+\t\t\tprintf(\"test_ring_nagative ring is not empty but it should be\\n\");\n+\t\t\tgoto test_fail;\n+\t\t}\n+\n+\t\t/* Tests if it would always fail to create ring with an used\n+\t\t * ring name.\n+\t\t */\n+\t\trt = test_ring_create(\"test_ring_negative\", esize[i], RING_SIZE,\n+\t\t\t\t\tSOCKET_ID_ANY, 0);\n+\t\tif (rt != NULL)\n+\t\t\tgoto test_fail;\n+\n+\t\trte_ring_free(rp);\n+\t}\n \n-\tfree(src);\n-\tfree(dst);\n \treturn 0;\n \n- fail:\n-\tfree(src);\n-\tfree(dst);\n+test_fail:\n+\n+\trte_ring_free(rp);\n \treturn -1;\n }\n \n+/*\n+ * Burst and bulk operations with sp/sc, mp/mc and default (during creation)\n+ */\n static int\n-test_ring_burst_basic(struct rte_ring *r)\n+test_ring_burst_bulk_tests(unsigned int api_type)\n {\n+\tstruct rte_ring *r;\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+\tunsigned int i, j;\n+\tunsigned int num_elems;\n+\tint rand;\n+\tconst unsigned int rsz = RING_SIZE - 1;\n+\n+\tfor (i = 0; i < RTE_DIM(esize); i++) {\n+\t\ttest_ring_print_test_string(\"Test standard ring\", api_type,\n+\t\t\t\t\t\tesize[i]);\n+\n+\t\t/* Create the ring */\n+\t\tr = test_ring_create(\"test_ring_burst_bulk_tests\", esize[i],\n+\t\t\t\t\tRING_SIZE, SOCKET_ID_ANY, 0);\n+\n+\t\t/* alloc dummy object pointers */\n+\t\tsrc = test_ring_calloc(RING_SIZE * 2, esize[i]);\n+\t\tif (src == NULL)\n+\t\t\tgoto fail;\n+\t\ttest_ring_mem_init(src, RING_SIZE * 2, esize[i]);\n+\t\tcur_src = src;\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(r, cur_src, 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(r, cur_src, 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(r, cur_src, 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(r, cur_dst, 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(r, cur_dst, 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(r, cur_dst, 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+\t\t/* alloc some room for copied objects */\n+\t\tdst = test_ring_calloc(RING_SIZE * 2, esize[i]);\n+\t\tif (dst == NULL)\n+\t\t\tgoto fail;\n+\t\tcur_dst = dst;\n \n-\tcur_src = src;\n-\tcur_dst = dst;\n+\t\tprintf(\"enqueue 1 obj\\n\");\n+\t\tret = test_ring_enqueue(r, cur_src, esize[i], 1, api_type);\n+\t\tif (ret != 1)\n+\t\t\tgoto fail;\n+\t\tcur_src = test_ring_inc_ptr(cur_src, esize[i], 1);\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(r, cur_src, MAX_BULK, NULL);\n-\t\tcur_src += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\tprintf(\"enqueue 2 objs\\n\");\n+\t\tret = test_ring_enqueue(r, cur_src, esize[i], 2, api_type);\n+\t\tif (ret != 2)\n \t\t\tgoto fail;\n-\t}\n+\t\tcur_src = test_ring_inc_ptr(cur_src, esize[i], 2);\n \n-\tprintf(\"Enqueue 2 objects, free entries = MAX_BULK - 2  \\n\");\n-\tret = rte_ring_sp_enqueue_burst(r, cur_src, 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(r, cur_src, 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(r, cur_src, 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(r, cur_dst, MAX_BULK, NULL);\n-\t\tcur_dst += MAX_BULK;\n+\t\tprintf(\"enqueue MAX_BULK objs\\n\");\n+\t\tret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK,\n+\t\t\t\t\t\tapi_type);\n \t\tif (ret != MAX_BULK)\n \t\t\tgoto fail;\n-\t}\n+\t\tcur_src = test_ring_inc_ptr(cur_src, esize[i], MAX_BULK);\n \n-\t/* Available memory space for the exact MAX_BULK entries */\n-\tret = rte_ring_sc_dequeue_burst(r, cur_dst, 2, NULL);\n-\tcur_dst += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tret = rte_ring_sc_dequeue_burst(r, cur_dst, 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(r, cur_src, 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(r, cur_src, 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(r, cur_src, 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(r, cur_dst, 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(r, cur_dst, 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(r, cur_dst, 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+\t\tprintf(\"dequeue 1 obj\\n\");\n+\t\tret = test_ring_dequeue(r, cur_dst, esize[i], 1, api_type);\n+\t\tif (ret != 1)\n+\t\t\tgoto fail;\n+\t\tcur_dst = test_ring_inc_ptr(cur_dst, esize[i], 1);\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(r, cur_src, MAX_BULK, NULL);\n-\t\tcur_src += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\tprintf(\"dequeue 2 objs\\n\");\n+\t\tret = test_ring_dequeue(r, cur_dst, esize[i], 2, api_type);\n+\t\tif (ret != 2)\n \t\t\tgoto fail;\n-\t\tret = rte_ring_mc_dequeue_burst(r, cur_dst, MAX_BULK, NULL);\n-\t\tcur_dst += MAX_BULK;\n+\t\tcur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);\n+\n+\t\tprintf(\"dequeue MAX_BULK objs\\n\");\n+\t\tret = test_ring_dequeue(r, cur_dst, esize[i], MAX_BULK,\n+\t\t\t\t\t\tapi_type);\n \t\tif (ret != MAX_BULK)\n \t\t\tgoto fail;\n-\t}\n+\t\tcur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK);\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+\t\t/* check data */\n+\t\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tcur_src = src;\n+\t\tcur_dst = dst;\n+\n+\t\tprintf(\"fill and empty the ring\\n\");\n+\t\tfor (j = 0; j < RING_SIZE / MAX_BULK; j++) {\n+\t\t\tret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tcur_src = test_ring_inc_ptr(cur_src, esize[i],\n+\t\t\t\t\t\t\t\tMAX_BULK);\n+\n+\t\t\tret = test_ring_dequeue(r, cur_dst, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tcur_dst = test_ring_inc_ptr(cur_dst, esize[i],\n+\t\t\t\t\t\t\t\tMAX_BULK);\n+\t\t}\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(r, cur_src, MAX_BULK, NULL);\n-\t\tcur_src += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\t/* check data */\n+\t\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\t\tprintf(\"data after dequeue is not the same\\n\");\n \t\t\tgoto fail;\n-\t}\n+\t\t}\n+\n+\t\tcur_src = src;\n+\t\tcur_dst = dst;\n+\n+\t\tprintf(\"Test enqueue without enough memory space\\n\");\n+\t\tfor (j = 0; j < (RING_SIZE/MAX_BULK - 1); j++) {\n+\t\t\tret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tcur_src = test_ring_inc_ptr(cur_src, esize[i],\n+\t\t\t\t\t\t\t\tMAX_BULK);\n+\t\t}\n+\n+\t\tprintf(\"Enqueue 2 objects, free entries = MAX_BULK - 2\\n\");\n+\t\tret = test_ring_enqueue(r, cur_src, esize[i], 2, api_type);\n+\t\tif (ret != 2)\n+\t\t\tgoto fail;\n+\t\tcur_src = test_ring_inc_ptr(cur_src, esize[i], 2);\n+\n+\t\tprintf(\"Enqueue the remaining entries = MAX_BULK - 3\\n\");\n+\t\t/* Bulk APIs enqueue exact number of elements */\n+\t\tif ((api_type & TEST_RING_ELEM_BULK) == TEST_RING_ELEM_BULK)\n+\t\t\tnum_elems = MAX_BULK - 3;\n+\t\telse\n+\t\t\tnum_elems = MAX_BULK;\n+\t\t/* Always one free entry left */\n+\t\tret = test_ring_enqueue(r, cur_src, esize[i], num_elems,\n+\t\t\t\t\t\tapi_type);\n+\t\tif (ret != MAX_BULK - 3)\n+\t\t\tgoto fail;\n+\t\tcur_src = test_ring_inc_ptr(cur_src, esize[i], MAX_BULK - 3);\n \n-\t/* Available memory space for the exact MAX_BULK objects */\n-\tret = rte_ring_mp_enqueue_burst(r, cur_src, 2, NULL);\n-\tcur_src += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n+\t\tprintf(\"Test if ring is full\\n\");\n+\t\tif (rte_ring_full(r) != 1)\n+\t\t\tgoto fail;\n \n-\tret = rte_ring_mp_enqueue_burst(r, cur_src, MAX_BULK, NULL);\n-\tcur_src += MAX_BULK - 3;\n-\tif (ret != MAX_BULK - 3)\n-\t\tgoto fail;\n+\t\tprintf(\"Test enqueue for a full entry\\n\");\n+\t\tret = test_ring_enqueue(r, cur_src, esize[i], MAX_BULK,\n+\t\t\t\t\t\tapi_type);\n+\t\tif (ret != 0)\n+\t\t\tgoto fail;\n \n+\t\tprintf(\"Test dequeue without enough objects\\n\");\n+\t\tfor (j = 0; j < RING_SIZE / MAX_BULK - 1; j++) {\n+\t\t\tret = test_ring_dequeue(r, cur_dst, esize[i], MAX_BULK,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tif (ret != MAX_BULK)\n+\t\t\t\tgoto fail;\n+\t\t\tcur_dst = test_ring_inc_ptr(cur_dst, esize[i],\n+\t\t\t\t\t\t\t\tMAX_BULK);\n+\t\t}\n+\n+\t\t/* Available memory space for the exact MAX_BULK entries */\n+\t\tret = test_ring_dequeue(r, cur_dst, esize[i], 2, api_type);\n+\t\tif (ret != 2)\n+\t\t\tgoto fail;\n+\t\tcur_dst = test_ring_inc_ptr(cur_dst, esize[i], 2);\n+\n+\t\t/* Bulk APIs enqueue exact number of elements */\n+\t\tif ((api_type & TEST_RING_ELEM_BULK) == TEST_RING_ELEM_BULK)\n+\t\t\tnum_elems = MAX_BULK - 3;\n+\t\telse\n+\t\t\tnum_elems = MAX_BULK;\n+\t\tret = test_ring_dequeue(r, cur_dst, esize[i], num_elems,\n+\t\t\t\t\t\tapi_type);\n+\t\tif (ret != MAX_BULK - 3)\n+\t\t\tgoto fail;\n+\t\tcur_dst = test_ring_inc_ptr(cur_dst, esize[i], MAX_BULK - 3);\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(r, cur_dst, MAX_BULK, NULL);\n-\t\tcur_dst += MAX_BULK;\n-\t\tif (ret != MAX_BULK)\n+\t\tprintf(\"Test if ring is empty\\n\");\n+\t\t/* Check if ring is empty */\n+\t\tif (rte_ring_empty(r) != 1)\n \t\t\tgoto fail;\n-\t}\n \n-\t/* Available objects - the exact MAX_BULK */\n-\tret = rte_ring_mc_dequeue_burst(r, cur_dst, 2, NULL);\n-\tcur_dst += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tret = rte_ring_mc_dequeue_burst(r, cur_dst, 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\t/* check data */\n+\t\tif (memcmp(src, dst, cur_dst - dst)) {\n+\t\t\trte_hexdump(stdout, \"src\", src, cur_src - src);\n+\t\t\trte_hexdump(stdout, \"dst\", dst, cur_dst - dst);\n+\t\t\tprintf(\"data after dequeue is not the same\\n\");\n+\t\t\tgoto fail;\n+\t\t}\n+\n+\t\tprintf(\"Random full/empty test\\n\");\n+\t\tcur_src = src;\n+\t\tcur_dst = dst;\n+\n+\t\tfor (j = 0; j != TEST_RING_FULL_EMTPY_ITER; j++) {\n+\t\t\t/* random shift in the ring */\n+\t\t\trand = RTE_MAX(rte_rand() % RING_SIZE, 1UL);\n+\t\t\tprintf(\"%s: iteration %u, random shift: %u;\\n\",\n+\t\t\t    __func__, i, rand);\n+\t\t\tret = test_ring_enqueue(r, cur_src, esize[i], rand,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tTEST_RING_VERIFY(ret != 0);\n+\n+\t\t\tret = test_ring_dequeue(r, cur_dst, esize[i], rand,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tTEST_RING_VERIFY(ret == rand);\n+\n+\t\t\t/* fill the ring */\n+\t\t\tret = test_ring_enqueue(r, cur_src, esize[i], rsz,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tTEST_RING_VERIFY(ret != 0);\n+\n+\t\t\tTEST_RING_VERIFY(rte_ring_free_count(r) == 0);\n+\t\t\tTEST_RING_VERIFY(rsz == rte_ring_count(r));\n+\t\t\tTEST_RING_VERIFY(rte_ring_full(r));\n+\t\t\tTEST_RING_VERIFY(rte_ring_empty(r) == 0);\n+\n+\t\t\t/* empty the ring */\n+\t\t\tret = test_ring_dequeue(r, cur_dst, esize[i], rsz,\n+\t\t\t\t\t\t\tapi_type);\n+\t\t\tTEST_RING_VERIFY(ret == (int)rsz);\n+\t\t\tTEST_RING_VERIFY(rsz == rte_ring_free_count(r));\n+\t\t\tTEST_RING_VERIFY(rte_ring_count(r) == 0);\n+\t\t\tTEST_RING_VERIFY(rte_ring_full(r) == 0);\n+\t\t\tTEST_RING_VERIFY(rte_ring_empty(r));\n+\n+\t\t\t/* check data */\n+\t\t\tTEST_RING_VERIFY(memcmp(src, dst, rsz) == 0);\n+\t\t\trte_ring_dump(stdout, r);\n+\t\t}\n+\n+\t\t/* Free memory before test completed */\n+\t\trte_ring_free(r);\n+\t\trte_free(src);\n+\t\trte_free(dst);\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(r, cur_src, 2, NULL);\n-\tcur_src += 2;\n-\tif (ret != 2)\n-\t\tgoto fail;\n-\n-\tret = rte_ring_dequeue_burst(r, cur_dst, 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+fail:\n+\trte_ring_free(r);\n+\trte_free(src);\n+\trte_free(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(\"test_bad_ring_size\", RING_SIZE + 1, 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(\"test_bad_ring_size\", (RTE_RING_SZ_MASK + 1), 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(\"test\", RING_SIZE, 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(\"test_ring_count\",\n-\t\t\t4097, SOCKET_ID_ANY, 0 );\n-\tif(r != NULL){\n-\t\treturn -1;\n-\t}\n-\treturn 0;\n-}\n-\n-static int\n-test_lookup_null(void)\n-{\n-\tstruct rte_ring *rlp = rte_ring_lookup(\"ring_not_found\");\n-\tif (rlp ==NULL)\n-\tif (rte_errno != ENOENT){\n-\t\tprintf( \"test failed to returnn error on null pointer\\n\");\n-\t\treturn -1;\n-\t}\n-\treturn 0;\n-}\n-\n-/*\n- * it tests some more basic ring operations\n+ * Test default, single element, bulk and burst APIs\n  */\n static int\n test_ring_basic_ex(void)\n {\n \tint ret = -1;\n-\tunsigned i;\n+\tunsigned int i, j;\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(\"test_ring_basic_ex\", RING_SIZE, 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(rp, obj[i]);\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(rp, &obj[i]);\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(rp, obj, 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+\tvoid *obj = NULL;\n+\n+\tfor (i = 0; i < RTE_DIM(esize); i++) {\n+\t\tobj = test_ring_calloc(RING_SIZE, esize[i]);\n+\t\tif (obj == NULL) {\n+\t\t\tprintf(\"test_ring_basic_ex fail to rte_malloc\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\trp = test_ring_create(\"test_ring_basic_ex\", esize[i], RING_SIZE,\n+\t\t\t\t\tSOCKET_ID_ANY,\n+\t\t\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ);\n+\t\tif (rp == NULL) {\n+\t\t\tprintf(\"test_ring_basic_ex fail to create ring\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\tif (rte_ring_lookup(\"test_ring_basic_ex\") != rp) {\n+\t\t\tprintf(\"test_ring_basic_ex ring is not found\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\tif (rte_ring_empty(rp) != 1) {\n+\t\t\tprintf(\"test_ring_basic_ex ring is not empty but it should be\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\tprintf(\"%u ring entries are now free\\n\",\n+\t\t\trte_ring_free_count(rp));\n+\n+\t\tfor (j = 0; j < RING_SIZE; j++) {\n+\t\t\ttest_ring_enqueue(rp, obj, esize[i], 1,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);\n+\t\t}\n+\n+\t\tif (rte_ring_full(rp) != 1) {\n+\t\t\tprintf(\"test_ring_basic_ex ring is not full but it should be\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\tfor (j = 0; j < RING_SIZE; j++) {\n+\t\t\ttest_ring_dequeue(rp, obj, esize[i], 1,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);\n+\t\t}\n+\n+\t\tif (rte_ring_empty(rp) != 1) {\n+\t\t\tprintf(\"test_ring_basic_ex ring is not empty but it should be\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\t/* Following tests use the configured flags to decide\n+\t\t * SP/SC or MP/MC.\n+\t\t */\n+\t\t/* Covering the ring burst operation */\n+\t\tret = test_ring_enqueue(rp, obj, esize[i], 2,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);\n+\t\tif (ret != 2) {\n+\t\t\tprintf(\"test_ring_basic_ex: rte_ring_enqueue_burst fails\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\tret = test_ring_dequeue(rp, obj, esize[i], 2,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);\n+\t\tif (ret != 2) {\n+\t\t\tprintf(\"test_ring_basic_ex: rte_ring_dequeue_burst fails\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\t/* Covering the ring bulk operation */\n+\t\tret = test_ring_enqueue(rp, obj, esize[i], 2,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK);\n+\t\tif (ret != 2) {\n+\t\t\tprintf(\"test_ring_basic_ex: rte_ring_enqueue_bulk fails\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\tret = test_ring_dequeue(rp, obj, esize[i], 2,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK);\n+\t\tif (ret != 2) {\n+\t\t\tprintf(\"test_ring_basic_ex: rte_ring_dequeue_bulk fails\\n\");\n+\t\t\tgoto fail_test;\n+\t\t}\n+\n+\t\trte_ring_free(rp);\n+\t\trte_free(obj);\n+\t\trp = NULL;\n+\t\tobj = NULL;\n \t}\n \n-\tret = rte_ring_dequeue_burst(rp, obj, 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+\treturn 0;\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+\treturn -1;\n }\n \n+/*\n+ * Basic test cases with exact size ring.\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+\tstruct rte_ring *std_r = NULL, *exact_sz_r = NULL;\n+\tvoid *obj;\n+\tconst unsigned int ring_sz = 16;\n+\tunsigned int i, j;\n \tint ret = -1;\n \n-\tstd_ring = rte_ring_create(\"std\", ring_sz, 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(\"exact sz\", ring_sz, 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+\tfor (i = 0; i < RTE_DIM(esize); i++) {\n+\t\ttest_ring_print_test_string(\"Test exact size ring\",\n+\t\t\t\tTEST_RING_IGNORE_API_TYPE,\n+\t\t\t\tesize[i]);\n+\n+\t\t/* alloc object pointers */\n+\t\tobj = test_ring_calloc(16, esize[i]);\n+\t\tif (obj == NULL)\n+\t\t\tgoto test_fail;\n+\n+\t\tstd_r = test_ring_create(\"std\", esize[i], ring_sz,\n+\t\t\t\t\trte_socket_id(),\n+\t\t\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ);\n+\t\tif (std_r == NULL) {\n+\t\t\tprintf(\"%s: error, can't create std ring\\n\", __func__);\n+\t\t\tgoto test_fail;\n+\t\t}\n+\t\texact_sz_r = test_ring_create(\"exact sz\", esize[i], ring_sz,\n+\t\t\t\trte_socket_id(),\n+\t\t\t\tRING_F_SP_ENQ | RING_F_SC_DEQ |\n+\t\t\t\tRING_F_EXACT_SZ);\n+\t\tif (exact_sz_r == NULL) {\n+\t\t\tprintf(\"%s: error, can't create exact size ring\\n\",\n+\t\t\t\t\t__func__);\n+\t\t\tgoto test_fail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Check that the exact size ring is bigger than the\n+\t\t * standard ring\n+\t\t */\n+\t\tif (rte_ring_get_size(std_r) >= rte_ring_get_size(exact_sz_r)) {\n+\t\t\tprintf(\"%s: error, std ring (size: %u) is not smaller than exact size one (size %u)\\n\",\n+\t\t\t\t\t__func__,\n+\t\t\t\t\trte_ring_get_size(std_r),\n+\t\t\t\t\trte_ring_get_size(exact_sz_r));\n+\t\t\tgoto test_fail;\n+\t\t}\n+\t\t/*\n+\t\t * check that the exact_sz_ring can hold one more element\n+\t\t * than the standard ring. (16 vs 15 elements)\n+\t\t */\n+\t\tfor (j = 0; j < ring_sz - 1; j++) {\n+\t\t\ttest_ring_enqueue(std_r, obj, esize[i], 1,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);\n+\t\t\ttest_ring_enqueue(exact_sz_r, obj, esize[i], 1,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);\n+\t\t}\n+\t\tret = test_ring_enqueue(std_r, obj, esize[i], 1,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);\n+\t\tif (ret != -ENOBUFS) {\n+\t\t\tprintf(\"%s: error, unexpected successful enqueue\\n\",\n+\t\t\t\t__func__);\n+\t\t\tgoto test_fail;\n+\t\t}\n+\t\tret = test_ring_enqueue(exact_sz_r, obj, esize[i], 1,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE);\n+\t\tif (ret == -ENOBUFS) {\n+\t\t\tprintf(\"%s: error, enqueue failed\\n\", __func__);\n+\t\t\tgoto test_fail;\n+\t\t}\n+\n+\t\t/* check that dequeue returns the expected number of elements */\n+\t\tret = test_ring_dequeue(exact_sz_r, obj, esize[i], ring_sz,\n+\t\t\t\tTEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST);\n+\t\tif (ret != (int)ring_sz) {\n+\t\t\tprintf(\"%s: error, failed to dequeue expected nb of elements\\n\",\n+\t\t\t\t__func__);\n+\t\t\tgoto test_fail;\n+\t\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(std_ring, NULL);\n-\t\trte_ring_enqueue(exact_sz_ring, NULL);\n-\t}\n-\tif (rte_ring_enqueue(std_ring, NULL) != -ENOBUFS) {\n-\t\tprintf(\"%s: error, unexpected successful enqueue\\n\", __func__);\n-\t\tgoto end;\n-\t}\n-\tif (rte_ring_enqueue(exact_sz_ring, NULL) == -ENOBUFS) {\n-\t\tprintf(\"%s: error, enqueue failed\\n\", __func__);\n-\t\tgoto end;\n-\t}\n+\t\t/* check that the capacity function returns expected value */\n+\t\tif (rte_ring_get_capacity(exact_sz_r) != ring_sz) {\n+\t\t\tprintf(\"%s: error, incorrect ring capacity reported\\n\",\n+\t\t\t\t\t__func__);\n+\t\t\tgoto test_fail;\n+\t\t}\n \n-\t/* check that dequeue returns the expected number of elements */\n-\tif (rte_ring_dequeue_burst(exact_sz_ring, ptr_array,\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\trte_free(obj);\n+\t\trte_ring_free(std_r);\n+\t\trte_ring_free(exact_sz_r);\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+\treturn 0;\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+test_fail:\n+\trte_free(obj);\n+\trte_ring_free(std_r);\n+\trte_ring_free(exact_sz_r);\n+\treturn -1;\n }\n \n static int\n test_ring(void)\n {\n-\tstruct rte_ring *r = NULL;\n+\tunsigned int i, j;\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(\"test\", RING_SIZE, 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/* Negative test cases */\n+\tif (test_ring_negative_tests() < 0)\n \t\tgoto test_fail;\n-\t} else\n-\t\tprintf(\"Test detected odd count\\n\");\n \n-\tif ( test_lookup_null() < 0){\n-\t\tprintf(\"Test failed to detect NULL ring lookup\\n\");\n-\t\tgoto test_fail;\n-\t} else\n-\t\tprintf(\"Test detected NULL ring lookup\\n\");\n-\n-\t/* test of creating ring with wrong size */\n-\tif (test_ring_creation_with_wrong_size() < 0)\n+\t/* some more basic operations */\n+\tif (test_ring_basic_ex() < 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+\t/* Burst and bulk operations with sp/sc, mp/mc and default */\n+\tfor (j = TEST_RING_ELEM_BULK; j <= TEST_RING_ELEM_BURST; j <<= 1)\n+\t\tfor (i = TEST_RING_THREAD_DEF;\n+\t\t\t\t\ti <= TEST_RING_THREAD_MPMC; i <<= 1)\n+\t\t\tif (test_ring_burst_bulk_tests(i | j) < 0)\n+\t\t\t\tgoto test_fail;\n \n \tif (test_ring_with_exact_size() < 0)\n \t\tgoto test_fail;\n@@ -863,12 +692,9 @@ test_ring(void)\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 }\ndiff --git a/app/test/test_ring.h b/app/test/test_ring.h\nnew file mode 100644\nindex 000000000..26716e4f8\n--- /dev/null\n+++ b/app/test/test_ring.h\n@@ -0,0 +1,187 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(c) 2019 Arm Limited\n+ */\n+\n+#include <rte_malloc.h>\n+#include <rte_ring.h>\n+#include <rte_ring_elem.h>\n+\n+/* API type to call\n+ * rte_ring_<sp/mp or sc/mc>_enqueue_<bulk/burst>\n+ * TEST_RING_THREAD_DEF - Uses configured SPSC/MPMC calls\n+ * TEST_RING_THREAD_SPSC - Calls SP or SC API\n+ * TEST_RING_THREAD_MPMC - Calls MP or MC API\n+ */\n+#define TEST_RING_THREAD_DEF 1\n+#define TEST_RING_THREAD_SPSC 2\n+#define TEST_RING_THREAD_MPMC 4\n+\n+/* API type to call\n+ * SL - Calls single element APIs\n+ * BL - Calls bulk APIs\n+ * BR - Calls burst APIs\n+ */\n+#define TEST_RING_ELEM_SINGLE 8\n+#define TEST_RING_ELEM_BULK 16\n+#define TEST_RING_ELEM_BURST 32\n+\n+#define TEST_RING_IGNORE_API_TYPE ~0U\n+\n+/* This function is placed here as it is required for both\n+ * performance and functional tests.\n+ */\n+static inline struct rte_ring*\n+test_ring_create(const char *name, int esize, unsigned int count,\n+\t\tint socket_id, unsigned int flags)\n+{\n+\t/* Legacy queue APIs? */\n+\tif ((esize) == -1)\n+\t\treturn rte_ring_create((name), (count), (socket_id), (flags));\n+\telse\n+\t\treturn rte_ring_create_elem((name), (esize), (count),\n+\t\t\t\t\t\t(socket_id), (flags));\n+}\n+\n+static __rte_always_inline unsigned int\n+test_ring_enqueue(struct rte_ring *r, void **obj, int esize, unsigned int n,\n+\t\t\tunsigned int api_type)\n+{\n+\t/* Legacy queue APIs? */\n+\tif ((esize) == -1)\n+\t\tswitch (api_type) {\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_enqueue(r, obj);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_sp_enqueue(r, obj);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_mp_enqueue(r, obj);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_enqueue_bulk(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_sp_enqueue_bulk(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_mp_enqueue_bulk(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_enqueue_burst(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_sp_enqueue_burst(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_mp_enqueue_burst(r, obj, n, NULL);\n+\t\tdefault:\n+\t\t\tprintf(\"Invalid API type\\n\");\n+\t\t\treturn 0;\n+\t\t}\n+\telse\n+\t\tswitch (api_type) {\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_enqueue_elem(r, obj, esize);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_sp_enqueue_elem(r, obj, esize);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_mp_enqueue_elem(r, obj, esize);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_enqueue_bulk_elem(r, obj, esize, n,\n+\t\t\t\t\t\t\t\tNULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_sp_enqueue_bulk_elem(r, obj, esize, n,\n+\t\t\t\t\t\t\t\tNULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_mp_enqueue_bulk_elem(r, obj, esize, n,\n+\t\t\t\t\t\t\t\tNULL);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_enqueue_burst_elem(r, obj, esize, n,\n+\t\t\t\t\t\t\t\tNULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_sp_enqueue_burst_elem(r, obj, esize, n,\n+\t\t\t\t\t\t\t\tNULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_mp_enqueue_burst_elem(r, obj, esize, n,\n+\t\t\t\t\t\t\t\tNULL);\n+\t\tdefault:\n+\t\t\tprintf(\"Invalid API type\\n\");\n+\t\t\treturn 0;\n+\t\t}\n+}\n+\n+static __rte_always_inline unsigned int\n+test_ring_dequeue(struct rte_ring *r, void **obj, int esize, unsigned int n,\n+\t\t\tunsigned int api_type)\n+{\n+\t/* Legacy queue APIs? */\n+\tif ((esize) == -1)\n+\t\tswitch (api_type) {\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_dequeue(r, obj);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_sc_dequeue(r, obj);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_mc_dequeue(r, obj);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_dequeue_bulk(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_sc_dequeue_bulk(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_mc_dequeue_bulk(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_dequeue_burst(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_sc_dequeue_burst(r, obj, n, NULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_mc_dequeue_burst(r, obj, n, NULL);\n+\t\tdefault:\n+\t\t\tprintf(\"Invalid API type\\n\");\n+\t\t\treturn 0;\n+\t\t}\n+\telse\n+\t\tswitch (api_type) {\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_dequeue_elem(r, obj, esize);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_sc_dequeue_elem(r, obj, esize);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_SINGLE):\n+\t\t\treturn rte_ring_mc_dequeue_elem(r, obj, esize);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_dequeue_bulk_elem(r, obj, esize,\n+\t\t\t\t\t\t\t\tn, NULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_sc_dequeue_bulk_elem(r, obj, esize,\n+\t\t\t\t\t\t\t\tn, NULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BULK):\n+\t\t\treturn rte_ring_mc_dequeue_bulk_elem(r, obj, esize,\n+\t\t\t\t\t\t\t\tn, NULL);\n+\t\tcase (TEST_RING_THREAD_DEF | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_dequeue_burst_elem(r, obj, esize,\n+\t\t\t\t\t\t\t\tn, NULL);\n+\t\tcase (TEST_RING_THREAD_SPSC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_sc_dequeue_burst_elem(r, obj, esize,\n+\t\t\t\t\t\t\t\tn, NULL);\n+\t\tcase (TEST_RING_THREAD_MPMC | TEST_RING_ELEM_BURST):\n+\t\t\treturn rte_ring_mc_dequeue_burst_elem(r, obj, esize,\n+\t\t\t\t\t\t\t\tn, NULL);\n+\t\tdefault:\n+\t\t\tprintf(\"Invalid API type\\n\");\n+\t\t\treturn 0;\n+\t\t}\n+}\n+\n+/* This function is placed here as it is required for both\n+ * performance and functional tests.\n+ */\n+static __rte_always_inline void *\n+test_ring_calloc(unsigned int rsize, int esize)\n+{\n+\tunsigned int sz;\n+\tvoid *p;\n+\n+\t/* Legacy queue APIs? */\n+\tif (esize == -1)\n+\t\tsz = sizeof(void *);\n+\telse\n+\t\tsz = esize;\n+\n+\tp = rte_zmalloc(NULL, rsize * sz, RTE_CACHE_LINE_SIZE);\n+\tif (p == NULL)\n+\t\tprintf(\"Failed to allocate memory\\n\");\n+\n+\treturn p;\n+}\n",
    "prefixes": [
        "v8",
        "3/6"
    ]
}