get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 68197,
    "url": "http://patches.dpdk.org/api/patches/68197/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200411141428.1987768-8-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": "<20200411141428.1987768-8-jerinj@marvell.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/20200411141428.1987768-8-jerinj@marvell.com",
    "date": "2020-04-11T14:14:06",
    "name": "[v5,07/29] graph: implement create and destroy APIs",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "db73aea2f2a9342ff3a6635bea0b09f7d7c0c5f4",
    "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/20200411141428.1987768-8-jerinj@marvell.com/mbox/",
    "series": [
        {
            "id": 9314,
            "url": "http://patches.dpdk.org/api/series/9314/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=9314",
            "date": "2020-04-11T14:13:59",
            "name": "graph: introduce graph subsystem",
            "version": 5,
            "mbox": "http://patches.dpdk.org/series/9314/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/68197/comments/",
    "check": "success",
    "checks": "http://patches.dpdk.org/api/patches/68197/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 28D99A05A0;\n\tSat, 11 Apr 2020 16:15:52 +0200 (CEST)",
            "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 5AA341C205;\n\tSat, 11 Apr 2020 16:15:00 +0200 (CEST)",
            "from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com\n [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id D7C401C205\n for <dev@dpdk.org>; Sat, 11 Apr 2020 16:14:58 +0200 (CEST)",
            "from pps.filterd (m0045851.ppops.net [127.0.0.1])\n by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id\n 03BEEuio023864; Sat, 11 Apr 2020 07:14:57 -0700",
            "from sc-exch02.marvell.com ([199.233.58.182])\n by mx0b-0016f401.pphosted.com with ESMTP id 30bddkgarb-3\n (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT);\n Sat, 11 Apr 2020 07:14:57 -0700",
            "from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com\n (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2;\n Sat, 11 Apr 2020 07:14:50 -0700",
            "from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com\n (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend\n Transport; Sat, 11 Apr 2020 07:14:50 -0700",
            "from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14])\n by maili.marvell.com (Postfix) with ESMTP id 936CF3F7040;\n Sat, 11 Apr 2020 07:14:47 -0700 (PDT)"
        ],
        "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=81a+pumq+ReAVxRC7S3FWWE+2W6wWPQ+DIQV/Abcndw=;\n b=uFAgYNMEXHKcw4Sn86m+fxrvm5tUgWVHbwH6D+RTy/Eafz02VY+svAzfrSaomPUHhfJB\n QEadCUDY7kx17KbAjnUvfTnlI/JuK5Hk2xa7oLzBdrzy3cFux1q6h/ojZyFTAQFsJPIn\n pgZ1xV6Ks0F1LVT64l2+qqlyH63Q8tDF/+owjaPUJTWRoQri904chW7c49Vk6n127dqb\n 2562EY9Pcc1nQtg7CUAH5f5lOTYoKL8CRF9E47SZZZJjQPQgybss8+y4mHBQ8/U4WJPt\n dn5SCy8C6NS1CBxKSyV1K4DDX2jIl1cjHOi9mC2tpEmYrw/ueIl1os45hUYU9HN3aiqt Zg==",
        "From": "<jerinj@marvell.com>",
        "To": "Jerin Jacob <jerinj@marvell.com>, Kiran Kumar K <kirankumark@marvell.com>",
        "CC": "<dev@dpdk.org>, <thomas@monjalon.net>, <david.marchand@redhat.com>,\n <mdr@ashroe.eu>, <mattias.ronnblom@ericsson.com>,\n <pbhagavatula@marvell.com>, <ndabilpuram@marvell.com>,\n <xiao.w.wang@intel.com>, <amo@semihalf.com>",
        "Date": "Sat, 11 Apr 2020 19:44:06 +0530",
        "Message-ID": "<20200411141428.1987768-8-jerinj@marvell.com>",
        "X-Mailer": "git-send-email 2.25.1",
        "In-Reply-To": "<20200411141428.1987768-1-jerinj@marvell.com>",
        "References": "<20200405085613.1336841-1-jerinj@marvell.com>\n <20200411141428.1987768-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.676\n definitions=2020-04-11_04:2020-04-09,\n 2020-04-11 signatures=0",
        "Subject": "[dpdk-dev] [PATCH v5 07/29] graph: implement create and destroy 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": "From: Jerin Jacob <jerinj@marvell.com>\n\nAdding graph specific API implementations like graph create\nand graph destroy. This detect loops in the graph,\ncheck for isolated nodes and operation to verify the validity of\ngraph.\n\nSigned-off-by: Jerin Jacob <jerinj@marvell.com>\nSigned-off-by: Kiran Kumar K <kirankumark@marvell.com>\nSigned-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>\nSigned-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>\n---\n lib/librte_graph/graph.c               | 319 +++++++++++++++++++++++++\n lib/librte_graph/rte_graph_version.map |   2 +\n 2 files changed, 321 insertions(+)",
    "diff": "diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c\nindex e1930b7d2..f4e02fdfc 100644\n--- a/lib/librte_graph/graph.c\n+++ b/lib/librte_graph/graph.c\n@@ -2,13 +2,33 @@\n  * Copyright(C) 2020 Marvell International Ltd.\n  */\n \n+#include <fnmatch.h>\n+#include <stdbool.h>\n+\n+#include <rte_common.h>\n+#include <rte_debug.h>\n+#include <rte_errno.h>\n #include <rte_malloc.h>\n+#include <rte_memzone.h>\n #include <rte_spinlock.h>\n+#include <rte_string_fns.h>\n \n #include \"graph_private.h\"\n \n+static struct graph_head graph_list = STAILQ_HEAD_INITIALIZER(graph_list);\n static rte_spinlock_t graph_lock = RTE_SPINLOCK_INITIALIZER;\n+static rte_graph_t graph_id;\n int rte_graph_logtype;\n+\n+#define GRAPH_ID_CHECK(id) ID_CHECK(id, graph_id)\n+\n+/* Private functions */\n+struct graph_head *\n+graph_list_head_get(void)\n+{\n+\treturn &graph_list;\n+}\n+\n void\n graph_spinlock_lock(void)\n {\n@@ -21,6 +41,305 @@ graph_spinlock_unlock(void)\n \trte_spinlock_unlock(&graph_lock);\n }\n \n+static int\n+graph_node_add(struct graph *graph, struct node *node)\n+{\n+\tstruct graph_node *graph_node;\n+\tsize_t sz;\n+\n+\t/* Skip the duplicate nodes */\n+\tSTAILQ_FOREACH(graph_node, &graph->node_list, next)\n+\t\tif (strncmp(node->name, graph_node->node->name,\n+\t\t\t    RTE_NODE_NAMESIZE) == 0)\n+\t\t\treturn 0;\n+\n+\t/* Allocate new graph node object */\n+\tsz = sizeof(*graph_node) + node->nb_edges * sizeof(struct node *);\n+\tgraph_node = calloc(1, sz);\n+\n+\tif (graph_node == NULL)\n+\t\tSET_ERR_JMP(ENOMEM, free, \"Failed to calloc %s object\",\n+\t\t\t    node->name);\n+\n+\t/* Initialize the graph node */\n+\tgraph_node->node = node;\n+\n+\t/* Add to graph node list */\n+\tSTAILQ_INSERT_TAIL(&graph->node_list, graph_node, next);\n+\treturn 0;\n+\n+free:\n+\tfree(graph_node);\n+\treturn -rte_errno;\n+}\n+\n+static struct graph_node *\n+node_to_graph_node(struct graph *graph, struct node *node)\n+{\n+\tstruct graph_node *graph_node;\n+\n+\tSTAILQ_FOREACH(graph_node, &graph->node_list, next)\n+\t\tif (graph_node->node == node)\n+\t\t\treturn graph_node;\n+\n+\tSET_ERR_JMP(ENODEV, fail, \"Found isolated node %s\", node->name);\n+fail:\n+\treturn NULL;\n+}\n+\n+static int\n+graph_node_edges_add(struct graph *graph)\n+{\n+\tstruct graph_node *graph_node;\n+\tstruct node *adjacency;\n+\tconst char *next;\n+\trte_edge_t i;\n+\n+\tSTAILQ_FOREACH(graph_node, &graph->node_list, next) {\n+\t\tfor (i = 0; i < graph_node->node->nb_edges; i++) {\n+\t\t\tnext = graph_node->node->next_nodes[i];\n+\t\t\tadjacency = node_from_name(next);\n+\t\t\tif (adjacency == NULL)\n+\t\t\t\tSET_ERR_JMP(EINVAL, fail,\n+\t\t\t\t\t    \"Node %s not registered\", next);\n+\t\t\tif (graph_node_add(graph, adjacency))\n+\t\t\t\tgoto fail;\n+\t\t}\n+\t}\n+\treturn 0;\n+fail:\n+\treturn -rte_errno;\n+}\n+\n+static int\n+graph_adjacency_list_update(struct graph *graph)\n+{\n+\tstruct graph_node *graph_node, *tmp;\n+\tstruct node *adjacency;\n+\tconst char *next;\n+\trte_edge_t i;\n+\n+\tSTAILQ_FOREACH(graph_node, &graph->node_list, next) {\n+\t\tfor (i = 0; i < graph_node->node->nb_edges; i++) {\n+\t\t\tnext = graph_node->node->next_nodes[i];\n+\t\t\tadjacency = node_from_name(next);\n+\t\t\tif (adjacency == NULL)\n+\t\t\t\tSET_ERR_JMP(EINVAL, fail,\n+\t\t\t\t\t    \"Node %s not registered\", next);\n+\t\t\ttmp = node_to_graph_node(graph, adjacency);\n+\t\t\tif (tmp == NULL)\n+\t\t\t\tgoto fail;\n+\t\t\tgraph_node->adjacency_list[i] = tmp;\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+fail:\n+\treturn -rte_errno;\n+}\n+\n+static int\n+expand_pattern_to_node(struct graph *graph, const char *pattern)\n+{\n+\tstruct node_head *node_head = node_list_head_get();\n+\tbool found = false;\n+\tstruct node *node;\n+\n+\t/* Check for pattern match */\n+\tSTAILQ_FOREACH(node, node_head, next) {\n+\t\tif (fnmatch(pattern, node->name, 0) == 0) {\n+\t\t\tif (graph_node_add(graph, node))\n+\t\t\t\tgoto fail;\n+\t\t\tfound = true;\n+\t\t}\n+\t}\n+\tif (found == false)\n+\t\tSET_ERR_JMP(EFAULT, fail, \"Pattern %s node not found\", pattern);\n+\n+\treturn 0;\n+fail:\n+\treturn -rte_errno;\n+}\n+\n+static void\n+graph_cleanup(struct graph *graph)\n+{\n+\tstruct graph_node *graph_node;\n+\n+\twhile (!STAILQ_EMPTY(&graph->node_list)) {\n+\t\tgraph_node = STAILQ_FIRST(&graph->node_list);\n+\t\tSTAILQ_REMOVE_HEAD(&graph->node_list, next);\n+\t\tfree(graph_node);\n+\t}\n+}\n+\n+static int\n+graph_node_init(struct graph *graph)\n+{\n+\tstruct graph_node *graph_node;\n+\tconst char *name;\n+\tint rc;\n+\n+\tSTAILQ_FOREACH(graph_node, &graph->node_list, next) {\n+\t\tif (graph_node->node->init) {\n+\t\t\tname = graph_node->node->name;\n+\t\t\trc = graph_node->node->init(\n+\t\t\t\tgraph->graph,\n+\t\t\t\tgraph_node_name_to_ptr(graph->graph, name));\n+\t\t\tif (rc)\n+\t\t\t\tSET_ERR_JMP(rc, err, \"Node %s init() failed\",\n+\t\t\t\t\t    name);\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+err:\n+\treturn -rte_errno;\n+}\n+\n+static void\n+graph_node_fini(struct graph *graph)\n+{\n+\tstruct graph_node *graph_node;\n+\n+\tSTAILQ_FOREACH(graph_node, &graph->node_list, next)\n+\t\tif (graph_node->node->fini)\n+\t\t\tgraph_node->node->fini(\n+\t\t\t\tgraph->graph,\n+\t\t\t\tgraph_node_name_to_ptr(graph->graph,\n+\t\t\t\t\t\t       graph_node->node->name));\n+}\n+\n+rte_graph_t\n+rte_graph_create(const char *name, struct rte_graph_param *prm)\n+{\n+\trte_node_t src_node_count;\n+\tstruct graph *graph;\n+\tconst char *pattern;\n+\tuint16_t i;\n+\n+\tgraph_spinlock_lock();\n+\n+\t/* Check arguments sanity */\n+\tif (prm == NULL)\n+\t\tSET_ERR_JMP(EINVAL, fail, \"Param should not be NULL\");\n+\n+\tif (name == NULL)\n+\t\tSET_ERR_JMP(EINVAL, fail, \"Graph name should not be NULL\");\n+\n+\t/* Check for existence of duplicate graph */\n+\tSTAILQ_FOREACH(graph, &graph_list, next)\n+\t\tif (strncmp(name, graph->name, RTE_GRAPH_NAMESIZE) == 0)\n+\t\t\tSET_ERR_JMP(EEXIST, fail, \"Found duplicate graph %s\",\n+\t\t\t\t    name);\n+\n+\t/* Create graph object */\n+\tgraph = calloc(1, sizeof(*graph));\n+\tif (graph == NULL)\n+\t\tSET_ERR_JMP(ENOMEM, fail, \"Failed to calloc graph object\");\n+\n+\t/* Initialize the graph object */\n+\tSTAILQ_INIT(&graph->node_list);\n+\tif (rte_strscpy(graph->name, name, RTE_GRAPH_NAMESIZE) < 0)\n+\t\tSET_ERR_JMP(E2BIG, free, \"Too big name=%s\", name);\n+\n+\t/* Expand node pattern and add the nodes to the graph */\n+\tfor (i = 0; i < prm->nb_node_patterns; i++) {\n+\t\tpattern = prm->node_patterns[i];\n+\t\tif (expand_pattern_to_node(graph, pattern))\n+\t\t\tgoto graph_cleanup;\n+\t}\n+\n+\t/* Go over all the nodes edges and add them to the graph */\n+\tif (graph_node_edges_add(graph))\n+\t\tgoto graph_cleanup;\n+\n+\t/* Update adjacency list of all nodes in the graph */\n+\tif (graph_adjacency_list_update(graph))\n+\t\tgoto graph_cleanup;\n+\n+\t/* Make sure at least a source node present in the graph */\n+\tsrc_node_count = graph_src_nodes_count(graph);\n+\tif (src_node_count == 0)\n+\t\tgoto graph_cleanup;\n+\n+\t/* Make sure no node is pointing to source node */\n+\tif (graph_node_has_edge_to_src_node(graph))\n+\t\tgoto graph_cleanup;\n+\n+\t/* Don't allow node has loop to self */\n+\tif (graph_node_has_loop_edge(graph))\n+\t\tgoto graph_cleanup;\n+\n+\t/* Do BFS from src nodes on the graph to find isolated nodes */\n+\tif (graph_has_isolated_node(graph))\n+\t\tgoto graph_cleanup;\n+\n+\t/* Initialize graph object */\n+\tgraph->socket = prm->socket_id;\n+\tgraph->src_node_count = src_node_count;\n+\tgraph->node_count = graph_nodes_count(graph);\n+\tgraph->id = graph_id;\n+\n+\t/* Allocate the Graph fast path memory and populate the data */\n+\tif (graph_fp_mem_create(graph))\n+\t\tgoto graph_cleanup;\n+\n+\t/* Call init() of the all the nodes in the graph */\n+\tif (graph_node_init(graph))\n+\t\tgoto graph_mem_destroy;\n+\n+\t/* All good, Lets add the graph to the list */\n+\tgraph_id++;\n+\tSTAILQ_INSERT_TAIL(&graph_list, graph, next);\n+\n+\tgraph_spinlock_unlock();\n+\treturn graph->id;\n+\n+graph_mem_destroy:\n+\tgraph_fp_mem_destroy(graph);\n+graph_cleanup:\n+\tgraph_cleanup(graph);\n+free:\n+\tfree(graph);\n+fail:\n+\tgraph_spinlock_unlock();\n+\treturn RTE_GRAPH_ID_INVALID;\n+}\n+\n+int\n+rte_graph_destroy(rte_graph_t id)\n+{\n+\tstruct graph *graph, *tmp;\n+\tint rc = -ENOENT;\n+\n+\tgraph_spinlock_lock();\n+\n+\tgraph = STAILQ_FIRST(&graph_list);\n+\twhile (graph != NULL) {\n+\t\ttmp = STAILQ_NEXT(graph, next);\n+\t\tif (graph->id == id) {\n+\t\t\t/* Call fini() of the all the nodes in the graph */\n+\t\t\tgraph_node_fini(graph);\n+\t\t\t/* Destroy graph fast path memory */\n+\t\t\trc = graph_fp_mem_destroy(graph);\n+\t\t\tif (rc)\n+\t\t\t\tSET_ERR_JMP(rc, done, \"Graph %s destroy failed\",\n+\t\t\t\t\t    graph->name);\n+\n+\t\t\tgraph_cleanup(graph);\n+\t\t\tSTAILQ_REMOVE(&graph_list, graph, graph, next);\n+\t\t\tfree(graph);\n+\t\t\tgraph_id--;\n+\t\t\tgoto done;\n+\t\t}\n+\t\tgraph = tmp;\n+\t}\n+done:\n+\tgraph_spinlock_unlock();\n+\treturn rc;\n+}\n+\n void __rte_noinline\n __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node)\n {\ndiff --git a/lib/librte_graph/rte_graph_version.map b/lib/librte_graph/rte_graph_version.map\nindex a9fe1b610..dcbd78c02 100644\n--- a/lib/librte_graph/rte_graph_version.map\n+++ b/lib/librte_graph/rte_graph_version.map\n@@ -4,6 +4,8 @@ EXPERIMENTAL {\n \t__rte_node_register;\n \t__rte_node_stream_alloc;\n \n+\trte_graph_create;\n+\trte_graph_destroy;\n \trte_node_clone;\n \trte_node_dump;\n \trte_node_edge_count;\n",
    "prefixes": [
        "v5",
        "07/29"
    ]
}