From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E26CEA059F; Sat, 11 Apr 2020 16:16:27 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D1D7C1C230; Sat, 11 Apr 2020 16:15:16 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id EA5D61C22A for ; Sat, 11 Apr 2020 16:15:15 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03BEEuis023864; Sat, 11 Apr 2020 07:15:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=J8Vox1aEOJLCY/5aKyzG7m09jBWRMlLCQxps+qrzx6c=; b=U6IOLgBXKDARD3psiBcMuctGoR2lldwZB8I7Awy7Ffi2brTQ3ijyzWTLCWQwjXXC02tB aMZ2WJwnEacRNzRzunTYNtL8ZcaFzmHZvKTDwCxw1zug7yx6VyVwepwD2o6658Mnhmw3 jLL8evnRlwv+3ch8yamu3b1r7HmWcFkh6fnj/UXrWm3ulqZZQpGSzYVvIsRsxJEEU6t9 HsEja1ijDaj0aAQDBTjQEw4JEAoBAv3fVUgofO/yZYD9skgISi4C4HpLVK2us4GZaguo XbhqBt+rHl7N7CcnxwViSJ06PFyRyi40VfjOyrVrqR/PspBKlIHjBgfQM2ujy+Nwhvd6 sA== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0b-0016f401.pphosted.com with ESMTP id 30bddkgarb-6 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 11 Apr 2020 07:15:14 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 11 Apr 2020 07:15:00 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 11 Apr 2020 07:14:59 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 11 Apr 2020 07:14:59 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 84D9F3F7040; Sat, 11 Apr 2020 07:14:56 -0700 (PDT) From: To: Jerin Jacob , Kiran Kumar K CC: , , , , , , , , Date: Sat, 11 Apr 2020 19:44:08 +0530 Message-ID: <20200411141428.1987768-10-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> <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 definitions=2020-04-11_04:2020-04-09, 2020-04-11 signatures=0 Subject: [dpdk-dev] [PATCH v5 09/29] graph: implement Graphviz export X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jerin Jacob Adding API implementation support exporting the graph object to file. This will export the graph to a file in Graphviz format. It can be viewed in many viewers such as https://dreampuf.github.io/GraphvizOnline/ Signed-off-by: Jerin Jacob Signed-off-by: Kiran Kumar K Signed-off-by: Pavan Nikhilesh Signed-off-by: Nithin Dabilpuram --- lib/librte_graph/graph.c | 53 ++++++++++++++++++++++++++ lib/librte_graph/rte_graph_version.map | 1 + 2 files changed, 54 insertions(+) diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c index 7a77cb5c8..61e212e03 100644 --- a/lib/librte_graph/graph.c +++ b/lib/librte_graph/graph.c @@ -473,6 +473,59 @@ __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node) node->realloc_count++; } +static int +graph_to_dot(FILE *f, struct graph *graph) +{ + const char *src_edge_color = " [color=blue]\n"; + const char *edge_color = "\n"; + struct graph_node *graph_node; + char *node_name; + rte_edge_t i; + int rc; + + rc = fprintf(f, "Digraph %s {\n\trankdir=LR;\n", graph->name); + if (rc < 0) + goto end; + + STAILQ_FOREACH(graph_node, &graph->node_list, next) { + node_name = graph_node->node->name; + for (i = 0; i < graph_node->node->nb_edges; i++) { + rc = fprintf(f, "\t\"%s\"->\"%s\"%s", node_name, + graph_node->adjacency_list[i]->node->name, + graph_node->node->flags & RTE_NODE_SOURCE_F + ? src_edge_color + : edge_color); + if (rc < 0) + goto end; + } + } + rc = fprintf(f, "}\n"); + if (rc < 0) + goto end; + + return 0; +end: + rte_errno = EBADF; + return -rte_errno; +} + +int +rte_graph_export(const char *name, FILE *f) +{ + struct graph *graph; + int rc = ENOENT; + + STAILQ_FOREACH(graph, &graph_list, next) { + if (strncmp(graph->name, name, RTE_GRAPH_NAMESIZE) == 0) { + rc = graph_to_dot(f, graph); + goto end; + } + } +end: + return -rc; +} + + rte_graph_t rte_graph_max_count(void) { diff --git a/lib/librte_graph/rte_graph_version.map b/lib/librte_graph/rte_graph_version.map index 5a2b13293..2797be044 100644 --- a/lib/librte_graph/rte_graph_version.map +++ b/lib/librte_graph/rte_graph_version.map @@ -6,6 +6,7 @@ EXPERIMENTAL { rte_graph_create; rte_graph_destroy; + rte_graph_export; rte_graph_from_name; rte_graph_id_to_name; rte_graph_lookup; -- 2.25.1