get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 65435,
    "url": "http://patches.dpdk.org/api/patches/65435/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200131170201.3236153-4-jerinj@marvell.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": "<20200131170201.3236153-4-jerinj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200131170201.3236153-4-jerinj@marvell.com",
    "date": "2020-01-31T17:01:59",
    "name": "[RFC,3/5] test: add graph functional tests",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "620d3d7d235eee02744fa5a28ef1b5563ecbf3ae",
    "submitter": {
        "id": 1188,
        "url": "http://patches.dpdk.org/api/people/1188/?format=api",
        "name": "Jerin Jacob Kollanukkaran",
        "email": "jerinj@marvell.com"
    },
    "delegate": {
        "id": 1,
        "url": "http://patches.dpdk.org/api/users/1/?format=api",
        "username": "tmonjalo",
        "first_name": "Thomas",
        "last_name": "Monjalon",
        "email": "thomas@monjalon.net"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200131170201.3236153-4-jerinj@marvell.com/mbox/",
    "series": [
        {
            "id": 8382,
            "url": "http://patches.dpdk.org/api/series/8382/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8382",
            "date": "2020-01-31T17:01:56",
            "name": "graph: introduce graph subsystem",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/8382/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/65435/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/65435/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 ECF3BA0524;\n\tFri, 31 Jan 2020 18:03:33 +0100 (CET)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id B7EA41C12B;\n\tFri, 31 Jan 2020 18:03:08 +0100 (CET)",
            "from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com\n [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 1434F1C11A;\n Fri, 31 Jan 2020 18:03:06 +0100 (CET)",
            "from pps.filterd (m0045849.ppops.net [127.0.0.1])\n by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n 00VGu8tv032198; Fri, 31 Jan 2020 09:03:00 -0800",
            "from sc-exch01.marvell.com ([199.233.58.181])\n by mx0a-0016f401.pphosted.com with ESMTP id 2xvpas8fxq-1\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Fri, 31 Jan 2020 09:03:00 -0800",
            "from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 31 Jan\n 2020 09:02:58 -0800",
            "from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com\n (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Fri, 31 Jan 2020 09:02:58 -0800",
            "from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14])\n by maili.marvell.com (Postfix) with ESMTP id 350833F703F;\n Fri, 31 Jan 2020 09:02:48 -0800 (PST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com;\n h=from : to : cc :\n subject : date : message-id : in-reply-to : references : mime-version :\n content-transfer-encoding : content-type; s=pfpt0818;\n bh=Q9HaaaKcIH1pjZrC7TLkRN00B+t5E1LxS2Yb+ybvjeI=;\n b=hku9qY6uXAAb4DkVKe4XnL60racUzcC+TUJ0pkouDv+YY88mWm78TH23/DXxtydtHl45\n JtI7C6dGLv17atl3kKt1ZfUpLoeXY/+UB9WE5KQpvc1HueBlvPN8RyvyZpqdlmx6HAbA\n Ajwzm6uJkvUwqHTQpD8wwo2M3Pe2+98k6yCngSJF2qBoJa3yiN3KKw/HUtfN3BGvlyf9\n htx7LBYQg9DDpUDtU22x1nqVv/gyFFup9mk0jbnmVyQHxS93vf6zW8xpuyzCisFvzNxW\n wt/TrUr9rFGQVjc2z0OUwOxJHmrs/qGJTZv+1mGVLTp2qpMRYYx7YieijmObUl0OWYG8 bw==",
        "From": "<jerinj@marvell.com>",
        "To": "<dev@dpdk.org>",
        "CC": "<pkapoor@marvell.com>, <ndabilpuram@marvell.com>,\n <kirankumark@marvell.com>, <pbhagavatula@marvell.com>,\n <pathreya@marvell.com>, <nsaxena@marvell.com>,\n <sshankarnara@marvell.com>, <honnappa.nagarahalli@arm.com>,\n <thomas@monjalon.net>, <david.marchand@redhat.com>,\n <ferruh.yigit@intel.com>, <arybchenko@solarflare.com>,\n <ajit.khaparde@broadcom.com>, <xiaolong.ye@intel.com>,\n <rasland@mellanox.com>, <maxime.coquelin@redhat.com>,\n <akhil.goyal@nxp.com>, <cristian.dumitrescu@intel.com>,\n <john.mcnamara@intel.com>, <bruce.richardson@intel.com>,\n <anatoly.burakov@intel.com>, <gavin.hu@arm.com>,\n <drc@linux.vnet.ibm.com>, <konstantin.ananyev@intel.com>,\n <pallavi.kadam@intel.com>, <olivier.matz@6wind.com>,\n <gage.eads@intel.com>, <nikhil.rao@intel.com>,\n <erik.g.carrillo@intel.com>, <hemant.agrawal@nxp.com>,\n <artem.andreev@oktetlabs.ru>, <sthemmin@microsoft.com>,\n <shahafs@mellanox.com>, <keith.wiles@intel.com>,\n <mattias.ronnblom@ericsson.com>, <jasvinder.singh@intel.com>,\n <vladimir.medvedkin@intel.com>, <mdr@ashroe.eu>, <techboard@dpdk.org>",
        "Date": "Fri, 31 Jan 2020 22:31:59 +0530",
        "Message-ID": "<20200131170201.3236153-4-jerinj@marvell.com>",
        "X-Mailer": "git-send-email 2.24.1",
        "In-Reply-To": "<20200131170201.3236153-1-jerinj@marvell.com>",
        "References": "<20200131170201.3236153-1-jerinj@marvell.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Content-Type": "text/plain",
        "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10434:6.0.138, 18.0.572\n definitions=2020-01-31_04:2020-01-31,\n 2020-01-31 signatures=0",
        "Subject": "[dpdk-dev]  [RFC PATCH 3/5] test: add graph functional tests",
        "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": "From: Kiran Kumar K <kirankumark@marvell.com>\n\nExample command to execute the test:\n\necho \"graph_autotest\" | sudo ./build/app/test/dpdk-test -c 0x30\n\nSigned-off-by: Kiran Kumar K <kirankumark@marvell.com>\n---\n app/test/Makefile     |   4 +\n app/test/meson.build  |   1 +\n app/test/test_graph.c | 820 ++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 825 insertions(+)\n create mode 100644 app/test/test_graph.c",
    "diff": "diff --git a/app/test/Makefile b/app/test/Makefile\nindex 57930c00b..e1dbe297e 100644\n--- a/app/test/Makefile\n+++ b/app/test/Makefile\n@@ -220,6 +220,10 @@ SRCS-y += test_event_timer_adapter.c\n SRCS-y += test_event_crypto_adapter.c\n endif\n \n+ifeq ($(CONFIG_RTE_LIBRTE_GRAPH), y)\n+SRCS-y += test_graph.c\n+endif\n+\n ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y)\n SRCS-y += test_rawdev.c\n endif\ndiff --git a/app/test/meson.build b/app/test/meson.build\nindex 7d761c8fa..d5d0c2173 100644\n--- a/app/test/meson.build\n+++ b/app/test/meson.build\n@@ -54,6 +54,7 @@ test_sources = files('commands.c',\n \t'test_fib6_perf.c',\n \t'test_func_reentrancy.c',\n \t'test_flow_classify.c',\n+\t'test_graph.c',\n \t'test_hash.c',\n \t'test_hash_functions.c',\n \t'test_hash_multiwriter.c',\ndiff --git a/app/test/test_graph.c b/app/test/test_graph.c\nnew file mode 100644\nindex 000000000..16a1373e8\n--- /dev/null\n+++ b/app/test/test_graph.c\n@@ -0,0 +1,820 @@\n+/* SPDX-License-Identifier: BSD-3-Clause\n+ * Copyright(C) 2020 Marvell International Ltd.\n+ */\n+#include <stdio.h>\n+#include <string.h>\n+#include <inttypes.h>\n+#include <signal.h>\n+#include <unistd.h>\n+#include <assert.h>\n+\n+#include <rte_errno.h>\n+#include <rte_graph.h>\n+#include <rte_graph_worker.h>\n+#include <rte_mbuf.h>\n+\n+#include \"test.h\"\n+\n+\n+uint16_t\n+test_node_worker_source(struct rte_graph *graph, struct rte_node *node,\n+\t\t\tvoid **objs, uint16_t nb_objs);\n+\n+uint16_t\n+test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs);\n+\n+uint16_t\n+test_node1_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs);\n+\n+uint16_t\n+test_node2_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs);\n+\n+uint16_t\n+test_node3_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs);\n+\n+#define MBUFF_SIZE 512\n+#define MAX_NODES 4\n+\n+static struct rte_mbuf mbuf[MAX_NODES + 1][MBUFF_SIZE];\n+static void *mbuf_p[MAX_NODES + 1][MBUFF_SIZE];\n+static rte_graph_t graph_id;\n+static uint64_t obj_stats[MAX_NODES + 1];\n+static uint64_t fn_calls[MAX_NODES + 1];\n+\n+const char *node_patterns[] = {\n+\t\"test_node_source1\",\n+\t\"test_node00\",\n+\t\"test_node00-test_node11\",\n+\t\"test_node00-test_node22\",\n+\t\"test_node00-test_node33\",\n+};\n+\n+const char *node_names[] = {\n+\t\"test_node00\",\n+\t\"test_node00-test_node11\",\n+\t\"test_node00-test_node22\",\n+\t\"test_node00-test_node33\",\n+};\n+\n+struct test_node_register {\n+#define NODE_NAMESIZE 64\n+        char name[NODE_NAMESIZE];\n+\trte_node_process_t process;\n+        uint16_t nb_edges;\n+        const char *next_nodes[MAX_NODES];\n+};\n+\n+typedef struct {\n+\tuint32_t idx;\n+\tstruct test_node_register  node;\n+} test_node_t;\n+\n+typedef struct {\n+\ttest_node_t test_node[MAX_NODES];\n+} test_main_t;\n+\n+static test_main_t test_main = {\n+\t.test_node  = {\n+\t\t{\n+\t\t\t.node = {\n+\t\t\t\t.name\t = \"test_node00\",\n+\t\t\t\t.process = test_node0_worker,\n+\t\t\t\t.nb_edges = 2,\n+\t\t\t\t.next_nodes = {\"test_node00-test_node11\",\n+\t\t\t\t\t\"test_node00-test_node22\"},\n+\t\t\t},\n+\t\t},\n+\t\t{\n+\t\t\t.node = {\n+\t\t\t\t.name\t = \"test_node11\",\n+\t\t\t\t.process = test_node1_worker,\n+\t\t\t\t.nb_edges = 1,\n+\t\t\t\t.next_nodes = {\"test_node00-test_node22\"},\n+\t\t\t},\n+\t\t},\n+\t\t{\n+\t\t\t.node = {\n+\t\t\t\t.name\t = \"test_node22\",\n+\t\t\t\t.process = test_node2_worker,\n+\t\t\t\t.nb_edges = 1,\n+\t\t\t\t.next_nodes = {\"test_node00-test_node33\"},\n+\t\t\t},\n+\t\t},\n+\t\t{\n+\t\t\t.node = {\n+\t\t\t\t.name\t = \"test_node33\",\n+\t\t\t\t.process = test_node3_worker,\n+\t\t\t\t.nb_edges = 1,\n+\t\t\t\t.next_nodes = {\"test_node00\"},\n+\t\t\t},\n+\t\t},\n+\t},\n+};\n+\n+static int node_init(const struct rte_graph *graph, struct rte_node *node)\n+{\n+\tRTE_SET_USED(graph);\n+\n+\t*(uint32_t*)node->ctx = node->id;\n+\n+\treturn 0;\n+}\n+\n+static struct rte_node_register test_node_source = {\n+\t.name\t = \"test_node_source1\",\n+\t.process = test_node_worker_source,\n+\t.flags   = RTE_NODE_SOURCE_F,\n+\t.nb_edges = 2,\n+\t.init = node_init,\n+\t.next_nodes = {\"test_node00\",\"test_node00-test_node11\"},\n+};\n+RTE_NODE_REGISTER(test_node_source);\n+\n+static struct rte_node_register test_node0 = {\n+\t.name\t = \"test_node00\",\n+\t.process = test_node0_worker,\n+\t.init = node_init,\n+};\n+RTE_NODE_REGISTER(test_node0);\n+\n+uint16_t\n+test_node_worker_source(struct rte_graph *graph, struct rte_node *node,\n+\t\t\tvoid **objs, uint16_t  nb_objs)\n+{\n+\tuint32_t obj_node0 = rand()%100, obj_node1;\n+\ttest_main_t *tm = &test_main;\n+\tstruct rte_mbuf *data;\n+\tvoid **next_stream;\n+\trte_node_t next;\n+\tuint32_t i;\n+\n+\tRTE_SET_USED(objs);\n+\n+\tnb_objs = RTE_GRAPH_BURST_SIZE;\n+\tobj_node0 = nb_objs * obj_node0 * 0.01;\n+\tnext = 0;\n+\tnext_stream = rte_node_next_stream_get(graph, node, next, obj_node0);\n+\tfor (i = 0; i < obj_node0; i++) {\n+\t\tdata = &mbuf[0][i];\n+\t\tdata->udata64 = ((uint64_t)tm->test_node[0].idx << 32) | i;\n+\t\tif ((i + 1) == obj_node0)\n+\t\t\tdata->udata64 |= (1 << 16);\n+\t\tnext_stream[i] = &mbuf[0][i];\n+\t}\n+\trte_node_next_stream_put(graph, node, next, obj_node0);\n+\n+\tobj_node1 = nb_objs - obj_node0;\n+\tnext = 1;\n+\tnext_stream = rte_node_next_stream_get(graph, node, next, obj_node1);\n+\tfor (i = 0; i < obj_node1; i++) {\n+\t\tdata = &mbuf[0][obj_node0 + i];\n+\t\tdata->udata64 = ((uint64_t)tm->test_node[1].idx << 32) | i;\n+\t\tif ((i + 1) == obj_node1)\n+\t\t\tdata->udata64 |= (1 << 16);\n+\t\tnext_stream[i] = &mbuf[0][obj_node0 + i];\n+\t}\n+\trte_node_next_stream_put(graph, node, next, obj_node1);\n+\n+\tobj_stats[0] += nb_objs;\n+\tfn_calls[0] += 1;\n+\treturn nb_objs;\n+}\n+\n+uint16_t\n+test_node0_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs)\n+{\n+\ttest_main_t *tm = &test_main;\n+\n+\tif (*(uint32_t*)node->ctx == test_node0.id) {\n+\t\tuint32_t obj_node0 = rand()%100, obj_node1;\n+\t\tstruct rte_mbuf *data;\n+\t\tuint8_t second_pass = 0;\n+\t\tuint32_t count = 0;\n+\t\tuint32_t i;\n+\n+\t\tobj_stats[1] += nb_objs;\n+\t\tfn_calls[1] += 1;\n+\n+\t\tfor (i = 0; i < nb_objs; i++) {\n+\t\t\tdata = (struct rte_mbuf*)objs[i];\n+\t\t\tif ((data->udata64 >> 32) != tm->test_node[0].idx) {\n+\t\t\t\tprintf(\"Data idx miss match at node 0, expected\"\n+\t\t\t\t      \" = %u got = %u\\n\",tm->test_node[0].idx,\n+\t\t\t\t       (uint32_t)(data->udata64 >> 32));\n+\t\t\t\tgoto end;\n+\t\t\t}\n+\n+\t\t\tif ((data->udata64 & 0xffff) != (i - count)) {\n+\t\t\t\tprintf(\"Expected buff count miss match at \"\n+\t\t\t\t       \"node 0\\n\");\n+\t\t\t\tgoto end;\n+\t\t\t}\n+\n+\t\t\tif (data->udata64 & (0x1 << 16))\n+\t\t\t\tcount = i + 1;\n+\t\t\tif (data->udata64 & (0x1 << 17))\n+\t\t\t\tsecond_pass = 1;\n+\t\t}\n+\n+\t\tif (count != i) {\n+\t\t\tprintf(\"Count missmatch at node 0\\n\");\n+\t\t\tgoto end;\n+\t\t}\n+\n+\t\tobj_node0 = nb_objs * obj_node0 * 0.01;\n+\t\tfor (i = 0; i < obj_node0; i++) {\n+\t\t\tdata = &mbuf[1][i];\n+\t\t\tdata->udata64 = ((uint64_t)tm->test_node[1].idx << 32)\n+\t\t\t\t| i;\n+\t\t\tif ((i + 1) == obj_node0)\n+\t\t\t\tdata->udata64 |= (1 << 16);\n+\t\t\tif (second_pass)\n+\t\t\t\tdata->udata64 |= (1 << 17);\n+\t\t}\n+\t\trte_node_enqueue(graph, node, 0, (void**)&mbuf_p[1][0],\n+\t\t\t\t obj_node0);\n+\n+\t\tobj_node1 = nb_objs - obj_node0;\n+\t\tfor (i = 0; i < obj_node1; i++) {\n+\t\t\tdata = &mbuf[1][obj_node0 + i];\n+\t\t\tdata->udata64 = ((uint64_t)tm->test_node[2].idx << 32)\n+\t\t\t\t| i;\n+\t\t\tif ((i + 1) == obj_node1)\n+\t\t\t\tdata->udata64 |= (1 << 16);\n+\t\t\tif (second_pass)\n+\t\t\t\tdata->udata64 |= (1 << 17);\n+\t\t}\n+\t\trte_node_enqueue(graph, node, 1,\n+\t\t\t\t (void**)&mbuf_p[1][obj_node0], obj_node1);\n+\n+\t} else if (*(uint32_t*)node->ctx == tm->test_node[1].idx)\n+\t\ttest_node1_worker(graph, node, objs, nb_objs);\n+\telse if (*(uint32_t*)node->ctx == tm->test_node[2].idx)\n+\t\ttest_node2_worker(graph, node, objs, nb_objs);\n+\telse if (*(uint32_t*)node->ctx == tm->test_node[3].idx)\n+\t\ttest_node3_worker(graph, node, objs, nb_objs);\n+\telse\n+\t\tassert(0);\n+end:\n+\t\treturn nb_objs;\n+}\n+\n+uint16_t\n+test_node1_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs)\n+{\n+\ttest_main_t *tm = &test_main;\n+\tuint8_t second_pass = 0;\n+\tuint32_t obj_node0 = 0;\n+\tstruct rte_mbuf *data;\n+\tuint32_t count = 0;\n+\tuint32_t i;\n+\n+\tobj_stats[2] += nb_objs;\n+\tfn_calls[2] += 1;\n+\tfor (i = 0; i < nb_objs; i++) {\n+\t\tdata = (struct rte_mbuf*)objs[i];\n+\t\tif ((data->udata64 >> 32) != tm->test_node[1].idx) {\n+\t\t\tprintf(\"Data idx miss match at node 1, expected = %u\"\n+\t\t\t       \" got = %u\\n\",tm->test_node[1].idx,\n+\t\t\t       (uint32_t)(data->udata64 >> 32));\n+\t\t\tgoto end;\n+\t\t}\n+\n+\t\tif ((data->udata64 & 0xffff) != (i - count)) {\n+\t\t\tprintf(\"Expected buff count miss match at node 1\\n\");\n+\t\t\tgoto end;\n+\t\t}\n+\n+\t\tif (data->udata64 & (0x1 << 16))\n+\t\t\tcount = i + 1;\n+\t\tif (data->udata64 & (0x1 << 17))\n+\t\t\tsecond_pass = 1;\n+\t}\n+\n+\tif (count != i) {\n+\t\tprintf(\"Count missmatch at node 1\\n\");\n+\t\tgoto end;\n+\t}\n+\n+\tobj_node0 = nb_objs;\n+\tfor (i = 0; i < obj_node0; i++) {\n+\t\tdata = &mbuf[2][i];\n+\t\tdata->udata64 = ((uint64_t)tm->test_node[2].idx << 32) | i;\n+\t\tif ((i + 1) == obj_node0)\n+\t\t\tdata->udata64 |= (1 << 16);\n+\t\tif (second_pass)\n+\t\t\tdata->udata64 |= (1 << 17);\n+\t}\n+\trte_node_enqueue(graph, node, 0,\n+\t\t\t (void**)&mbuf_p[2][0], obj_node0);\n+end:\n+\treturn nb_objs;\n+}\n+\n+uint16_t\n+test_node2_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs)\n+{\n+\ttest_main_t *tm = &test_main;\n+\tuint8_t second_pass = 0;\n+\tstruct rte_mbuf *data;\n+\tuint32_t count = 0;\n+\tuint32_t obj_node0;\n+\tuint32_t i;\n+\n+\tobj_stats[3] += nb_objs;\n+\tfn_calls[3] += 1;\n+\tfor (i = 0; i < nb_objs; i++) {\n+\t\tdata = (struct rte_mbuf*)objs[i];\n+\t\tif ((data->udata64 >> 32) != tm->test_node[2].idx) {\n+\t\t\tprintf(\"Data idx miss match at node 2, expected = %u\"\n+\t\t\t       \" got = %u\\n\",tm->test_node[2].idx,\n+\t\t\t       (uint32_t)(data->udata64 >> 32));\n+\t\t\tgoto end;\n+\t\t}\n+\n+\t\tif ((data->udata64 & 0xffff) != (i - count)) {\n+\t\t\tprintf(\"Expected buff count miss match at node 2\\n\");\n+\t\t\tgoto end;\n+\t\t}\n+\n+\t\tif (data->udata64 & (0x1 << 16))\n+\t\t\tcount = i + 1;\n+\t\tif (data->udata64 & (0x1 << 17))\n+\t\t\tsecond_pass = 1;\n+\t}\n+\n+\tif (count != i) {\n+\t\tprintf(\"Count missmatch at node 2\\n\");\n+\t\tgoto end;\n+\t}\n+\n+\tif (!second_pass) {\n+\t\tobj_node0 = nb_objs;\n+\t\tfor (i = 0; i < obj_node0; i++) {\n+\t\t\tdata = &mbuf[3][i];\n+\t\t\tdata->udata64 = ((uint64_t)tm->test_node[3].idx << 32)\n+\t\t\t\t| i;\n+\t\t\tif ((i + 1) == obj_node0)\n+\t\t\t\tdata->udata64 |= (1 << 16);\n+\t\t}\n+\t\trte_node_enqueue(graph, node, 0, (void**)&mbuf_p[3][0],\n+\t\t\t\t obj_node0);\n+\t}\n+end:\n+\treturn nb_objs;\n+}\n+\n+uint16_t\n+test_node3_worker(struct rte_graph *graph, struct rte_node *node, void **objs,\n+\t\t  uint16_t  nb_objs)\n+{\n+\ttest_main_t *tm = &test_main;\n+\tuint8_t second_pass = 0;\n+\tstruct rte_mbuf *data;\n+\tuint32_t count = 0;\n+\tuint32_t obj_node0;\n+\tuint32_t i;\n+\n+\tobj_stats[4] += nb_objs;\n+\tfn_calls[4] += 1;\n+\tfor (i = 0; i < nb_objs; i++) {\n+\t\tdata = (struct rte_mbuf*)objs[i];\n+\t\tif ((data->udata64 >> 32) != tm->test_node[3].idx) {\n+\t\t\tprintf(\"Data idx miss match at node 3, expected = %u\"\n+\t\t\t       \" got = %u\\n\",tm->test_node[3].idx,\n+\t\t\t       (uint32_t)(data->udata64 >> 32));\n+\t\t\tgoto end;\n+\t\t}\n+\n+\t\tif ((data->udata64 & 0xffff) != (i - count)) {\n+\t\t\tprintf(\"Expected buff count miss match at node 3\\n\");\n+\t\t\tgoto end;\n+\t\t}\n+\n+\t\tif (data->udata64 & (0x1 << 16))\n+\t\t\tcount = i + 1;\n+\t\tif (data->udata64 & (0x1 << 17))\n+\t\t\tsecond_pass = 1;\n+\t}\n+\n+\tif (count != i) {\n+\t\tprintf(\"Count missmatch at node 3\\n\");\n+\t\tgoto end;\n+\t}\n+\n+\tif (second_pass) {\n+\t\tprintf(\"Unexpected buffers are at node 3\\n\");\n+\t\tgoto end;\n+\t} else {\n+\t\tobj_node0 = nb_objs * 2;\n+\t\tfor (i = 0; i < obj_node0; i++) {\n+\t\t\tdata = &mbuf[4][i];\n+\t\t\tdata->udata64 = ((uint64_t)tm->test_node[0].idx << 32)\n+\t\t\t\t| i;\n+\t\t\tdata->udata64 |= (1 << 17);\n+\t\t\tif ((i + 1) == obj_node0)\n+\t\t\t\tdata->udata64 |= (1 << 16);\n+\t\t}\n+\t\trte_node_enqueue(graph, node, 0, (void**)&mbuf_p[4][0],\n+\t\t\t\t obj_node0);\n+\t}\n+end:\n+\treturn nb_objs;\n+}\n+\n+static int test_lookup_functions(void)\n+{\n+\ttest_main_t *tm = &test_main;\n+\tint i;\n+\n+\n+\t/* Verify the name with ID */\n+\tfor (i = 1; i < MAX_NODES; i++) {\n+\t\tchar *name = rte_node_id_to_name(tm->test_node[i].idx);\n+\t\tif (strcmp(name, node_names[i]) != 0) {\n+\t\t\tprintf(\"Test node name verify by ID = %d failed \"\n+\t\t\t       \"Expected = %s, got %s\\n\",\n+\t\t\t       i, node_names[i], name);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\t/* verify by name */\n+\tfor (i = 1; i < MAX_NODES; i++) {\n+\t\tuint32_t idx = rte_node_from_name(node_names[i]);\n+\t\tif (idx != tm->test_node[i].idx) {\n+\t\t\tprintf(\"Test node ID verify by name = %s failed \"\n+\t\t\t       \"Expected = %d, got %d\\n\",\n+\t\t\t       node_names[i], tm->test_node[i].idx,\n+\t\t\t       idx);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\t/* Verify edge count */\n+\tfor (i = 1; i < MAX_NODES; i++) {\n+\t\tuint32_t count = rte_node_edge_count(tm->test_node[i].idx);\n+\t\tif (count != tm->test_node[i].node.nb_edges) {\n+\t\t\tprintf(\"Test number of edges for node = %s failed \"\n+\t\t\t       \"Expected = %d, got = %d\\n\",\n+\t\t\t       tm->test_node[i].node.name,\n+\t\t\t       tm->test_node[i].node.nb_edges,\n+\t\t\t       count);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\t/* verify edge names */\n+\tfor (i = 1; i < MAX_NODES; i++) {\n+\t\tuint32_t j, count;\n+\t\tchar **next_edges;\n+\n+\t\tcount = rte_node_edge_get(tm->test_node[i].idx, NULL);\n+\t\tif (count != tm->test_node[i].node.nb_edges * sizeof(char*)) {\n+\t\t\tprintf(\"Test number of edge count for node = %s failed\"\n+\t\t\t       \" Expected = %d, got = %d\\n\",\n+\t\t\t       tm->test_node[i].node.name,\n+\t\t\t       tm->test_node[i].node.nb_edges,\n+\t\t\t       count);\n+\t\t\treturn -1;\n+\t\t}\n+\t\tnext_edges = malloc(count);\n+\t\tcount = rte_node_edge_get(tm->test_node[i].idx,\n+\t\t\t\t\t\t   next_edges);\n+\t\tif (count != tm->test_node[i].node.nb_edges) {\n+\t\t\tprintf(\"Test number of edges for node = %s failed \"\n+\t\t\t       \"Expected = %d, got %d\\n\",\n+\t\t\t       tm->test_node[i].node.name,\n+\t\t\t       tm->test_node[i].node.nb_edges,\n+\t\t\t       count);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tfor (j = 0; j < count; j++) {\n+\t\t\tif (strcmp(next_edges[j],\n+\t\t\t\t   tm->test_node[i].node.next_nodes[j]) != 0) {\n+\t\t\t\tprintf(\"Edge name miss match, expected = %s\"\n+\t\t\t\t       \" got = %s\\n\",\n+\t\t\t\t       tm->test_node[i].node.next_nodes[j],\n+\t\t\t\t       next_edges[j]);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t}\n+\t\tfree(next_edges);\n+\t}\n+\treturn 0;\n+}\n+\n+static int test_node_clone(void)\n+{\n+\ttest_main_t *tm = &test_main;\n+\tuint32_t node_id, dummy_id;\n+\tint i;\n+\n+\tnode_id = rte_node_from_name(\"test_node00\");\n+\ttm->test_node[0].idx = node_id;\n+\n+\t/* Clone with same name, should fail */\n+\tdummy_id = rte_node_clone(node_id, \"test_node00\");\n+\tif (!rte_node_is_invalid(dummy_id)) {\n+\t\tprintf(\"Got valid id when clone with same name, \"\n+\t\t      \" Expecting fail\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tfor (i = 1; i < MAX_NODES; i++) {\n+\t\ttm->test_node[i].idx =\n+\t\t\trte_node_clone(node_id, tm->test_node[i].node.name);\n+\t\tif (rte_node_is_invalid(tm->test_node[i].idx)) {\n+\t\t\tprintf(\"Got invalid node id \\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\t/* clone from cloned node should fail */\n+\tdummy_id = rte_node_clone(tm->test_node[1].idx, \"dummy_node\");\n+\tif (!rte_node_is_invalid(dummy_id)) {\n+\t\tprintf(\"Got valid node id when cloning from cloned node\"\n+\t\t       \" Expected fail\\n\");\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+static int test_update_edges(void)\n+{\n+\ttest_main_t *tm = &test_main;\n+\tuint32_t node_id;\n+\tuint16_t count;\n+\tint i;\n+\n+\n+\tnode_id = rte_node_from_name(\"test_node00\");\n+\tcount = rte_node_edge_update(node_id,\n+\t\t\t\t     0,\n+\t\t\t\t     tm->test_node[0].node.next_nodes,\n+\t\t\t\t     tm->test_node[0].node.nb_edges);\n+\tif (count != tm->test_node[0].node.nb_edges) {\n+\t\tprintf(\"Update edges failed expected: %d\"\n+\t\t       \" got = %d\\n\",\n+\t\t       tm->test_node[0].node.nb_edges,\n+\t\t       count);\n+\t\treturn -1;\n+\t}\n+\n+\tfor (i = 1; i < MAX_NODES; i++) {\n+\t\tcount = rte_node_edge_update(tm->test_node[i].idx,\n+\t\t\t\t\t     0,\n+\t\t\t\t\t     tm->test_node[i].node.next_nodes,\n+\t\t\t\ttm->test_node[i].node.nb_edges);\n+\t\tif (count != tm->test_node[i].node.nb_edges) {\n+\t\t\tprintf(\"Update edges failed expected: %d\"\n+\t\t\t       \" got = %d\\n\",\n+\t\t\t       tm->test_node[i].node.nb_edges,\n+\t\t\t       count);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tcount = rte_node_edge_shrink(tm->test_node[i].idx,\n+\t\t\t\ttm->test_node[i].node.nb_edges);\n+\t\tif (count != tm->test_node[i].node.nb_edges) {\n+\t\t\tprintf(\"Shrink edges failed\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static int test_create_graph(void)\n+{\n+\tconst char *node_patterns_dummy[] = {\n+\t\t\"test_node_source1\",\n+\t\t\"test_node00\",\n+\t\t\"test_node00-test_node11\",\n+\t\t\"test_node00-test_node22\",\n+\t\t\"test_node00-test_node33\",\n+\t\t\"test_node00-dummy_node\",\n+\t};\n+\tstruct rte_graph_param gconf = {\n+\t\t.socket_id = SOCKET_ID_ANY,\n+\t\t.nb_node_patterns = 6,\n+\t\t.node_patterns = node_patterns_dummy,\n+\t};\n+\tuint32_t dummy_node_id;\n+\tuint32_t node_id;\n+\n+\n+\tnode_id = rte_node_from_name(\"test_node00\");\n+\tdummy_node_id = rte_node_clone(node_id, \"dummy_node\");\n+\tif (rte_node_is_invalid(dummy_node_id)) {\n+\t\tprintf(\"Got invalid node id \\n\");\n+\t\treturn -1;\n+\t}\n+\tgraph_id = rte_graph_create(\"worker0\", &gconf);\n+\tif (graph_id != RTE_GRAPH_ID_INVALID) {\n+\t\tprintf(\"Graph creation success with isolated node\"\n+\t\t       \" Expected graph creation fail\\n\");\n+\t\treturn -1;\n+\t}\n+\tgconf.nb_node_patterns = 5;\n+\tgconf.node_patterns = node_patterns;\n+\tgraph_id = rte_graph_create(\"worker0\", &gconf);\n+\tif (graph_id == RTE_GRAPH_ID_INVALID) {\n+\t\tprintf(\"Graph creation failed with error = %d\\n\", rte_errno);\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+static int test_graph_walk(void)\n+{\n+\tstruct rte_graph *graph = rte_graph_lookup(\"worker0\");\n+\tint i;\n+\n+\tif (!graph) {\n+\t\tprintf(\"Graph lookup failed\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tfor (i = 0; i < 5; i++) {\n+\t\trte_graph_walk(graph);\n+\t}\n+\n+\treturn 0;\n+}\n+\n+\n+static int test_graph_lookup_functions(void)\n+{\n+\ttest_main_t *tm = &test_main;\n+\tstruct rte_node *node;\n+\tint i;\n+\n+\n+\tfor (i = 0; i < MAX_NODES; i++) {\n+\t\tnode  = rte_graph_node_get(graph_id, tm->test_node[i].idx);\n+\t\tif (!node) {\n+\t\t\tprintf(\"rte_graph_node_get, failed for node = %d\\n\",\n+\t\t\t       tm->test_node[i].idx);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (tm->test_node[i].idx != node->id) {\n+\t\t\tprintf(\"Node id didn't match, expected = %d\"\n+\t\t\t       \" got = %d\\n\", tm->test_node[i].idx, node->id);\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\tif (strncmp(node->name, node_names[i], RTE_NODE_NAMESIZE)) {\n+\t\t\tprintf(\"Node name didn't match, expected = %s\"\n+\t\t\t       \" got %s\\n\",node_names[i], node->name);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\n+\tfor (i = 0; i < MAX_NODES; i++) {\n+\t\tnode  = rte_graph_node_get_by_name(\"worker0\", node_names[i]);\n+\t\tif (!node) {\n+\t\t\tprintf(\"rte_graph_node_get, failed for node = %d\\n\",\n+\t\t\t       tm->test_node[i].idx);\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (tm->test_node[i].idx != node->id) {\n+\t\t\tprintf(\"Node id didn't match, expected = %d\"\n+\t\t\t       \" got = %d\\n\", tm->test_node[i].idx, node->id);\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\tif (strncmp(node->name, node_names[i], RTE_NODE_NAMESIZE)) {\n+\t\t\tprintf(\"Node name didn't match, expected = %s\"\n+\t\t\t       \" got %s\\n\",node_names[i], node->name);\n+\t\t\treturn -1;\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+graph_cluster_stats_cb_t(bool is_first, bool is_last, void *cookie,\n+\t\t\t const struct rte_graph_cluster_node_stats *st)\n+{\n+\tint i;\n+\n+\tRTE_SET_USED(is_first);\n+\tRTE_SET_USED(is_last);\n+\tRTE_SET_USED(cookie);\n+\n+\tfor (i = 0; i < MAX_NODES + 1; i++) {\n+\t\trte_node_t id = rte_node_from_name(node_patterns[i]);\n+\t\tif (id == st->id) {\n+\t\t\tif (obj_stats[i] != st->objs) {\n+\t\t\t\tprintf(\"Obj count miss match for node = %s\"\n+\t\t\t\t       \"expected=%\"PRId64\" , got=%\"PRId64\"\\n\",\n+\t\t\t\t       node_patterns[i], obj_stats[i],\n+\t\t\t\t       st->objs);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\tif (fn_calls[i] != st->calls) {\n+\t\t\t\tprintf(\"func call miss match for node = %s\"\n+\t\t\t\t       \"expected= %\"PRId64\" , got=%\"PRId64\"\\n\",\n+\t\t\t\t       node_patterns[i], fn_calls[i],\n+\t\t\t\t       st->calls);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t}\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+test_print_stats(void)\n+{\n+\tstruct rte_graph_cluster_stats_param s_param;\n+\tstruct rte_graph_cluster_stats *stats;\n+\tconst char *pattern = \"worker0\";\n+\n+\tif (!rte_graph_has_stats_feature())\n+\t\treturn 0;\n+\n+\t/* Prepare stats object */\n+\tmemset(&s_param, 0, sizeof(s_param));\n+\ts_param.f = stdout;\n+\ts_param.socket_id = SOCKET_ID_ANY;\n+\ts_param.graph_patterns = &pattern;\n+\ts_param.nb_graph_patterns =  1;\n+\ts_param.fn = graph_cluster_stats_cb_t;\n+\n+\tstats = rte_graph_cluster_stats_create(&s_param);\n+\tif (stats == NULL) {\n+\t\tprintf(\"Unable to get stats\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* Clear screen and move to top left */\n+\trte_graph_cluster_stats_get(stats, 0);\n+\n+\trte_graph_cluster_stats_destroy(stats);\n+\n+\treturn 0;\n+}\n+\n+static int graph_setup(void)\n+{\n+\tint i, j;\n+\n+\tfor (i = 0; i <= MAX_NODES; i++) {\n+\t\tfor (j = 0 ; j < MBUFF_SIZE; j++) {\n+\t\t\tmbuf_p[i][j] = &mbuf[i][j];\n+\t\t}\n+\t}\n+\n+\tif (test_node_clone()) {\n+\t\tprintf(\"test_node_clone: fail\\n\");\n+\t\treturn -1;\n+\t}\n+\tprintf(\"test_node_clone: pass\\n\");\n+\treturn 0;\n+}\n+\n+static void graph_teardown(void)\n+{\n+\trte_graph_t id;\n+\n+\tid = rte_graph_destroy(\"worker0\");\n+\tif (id == RTE_GRAPH_ID_INVALID) {\n+\t\tprintf(\"Graph Destroy failed\\n\");\n+\t}\n+}\n+\n+static struct unit_test_suite graph_testsuite = {\n+\t.suite_name = \"Graph library test suite\",\n+\t.setup = graph_setup,\n+\t.teardown = graph_teardown,\n+\t.unit_test_cases = {\n+\t\tTEST_CASE(test_update_edges),\n+\t\tTEST_CASE(test_lookup_functions),\n+\t\tTEST_CASE(test_create_graph),\n+\t\tTEST_CASE(test_graph_lookup_functions),\n+\t\tTEST_CASE(test_graph_walk),\n+\t\tTEST_CASE(test_print_stats),\n+\t\t// add test case for rte_graph_cluster_stats_reset\n+\t\tTEST_CASES_END(), /**< NULL terminate unit test array */\n+\t}\n+};\n+\n+static int\n+graph_autotest_fn(void)\n+{\n+\treturn unit_test_suite_runner(&graph_testsuite);\n+}\n+\n+REGISTER_TEST_COMMAND(graph_autotest, graph_autotest_fn);\n",
    "prefixes": [
        "RFC",
        "3/5"
    ]
}