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 19C9FA059F; Sat, 11 Apr 2020 16:15:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CEB731C1DB; Sat, 11 Apr 2020 16:14:41 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 852221C1AF for ; Sat, 11 Apr 2020 16:14:40 +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 03BEB7Nn020541; Sat, 11 Apr 2020 07:14:39 -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=FjV8CTno24d6ikalk8LVkARddTUkAayMMhKZ97hxCmk=; b=CgmYZ7NX4CwaJprXoW29aTFZnaRjA7Ksc+qylv51Zl7fSA6BO2ujU6Ips/jAnC8wNXka 4VOkP//jdoNQVzZRmQ87NO8BV3Rbuk270taPYqr07+GWiqvEA7KplMPX3qTw96VIV60v L5POfkP2L8URV+75C7ty4bFQDrwmom2mAFTXrkQle0PuMQtF7bq24o3M6wif0FRXfXp4 KQEutGxogxGbTPpczVHS5bCSP/LtiFHEriPjD03GYmgSsuHfkJfLbAx6lbq4eCbmSNkK QpTABHKe3x9uirS756D6Eo3X+2N17y38lrlq1Q8Z4fnY1igw8vKrfuL4MIXxrTKTpBaz AQ== Received: from sc-exch04.marvell.com ([199.233.58.184]) by mx0b-0016f401.pphosted.com with ESMTP id 30bddkgaqw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sat, 11 Apr 2020 07:14:39 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH04.marvell.com (10.93.176.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 11 Apr 2020 07:14:37 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 11 Apr 2020 07:14:37 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 214103F7041; Sat, 11 Apr 2020 07:14:33 -0700 (PDT) From: To: Jerin Jacob , Kiran Kumar K CC: , , , , , , , , Date: Sat, 11 Apr 2020 19:44:03 +0530 Message-ID: <20200411141428.1987768-5-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 04/29] graph: implement node debug routines 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 node debug API implementation support to dump single or all the node objects to the given file. Signed-off-by: Jerin Jacob Signed-off-by: Kiran Kumar K Signed-off-by: Pavan Nikhilesh Signed-off-by: Nithin Dabilpuram --- lib/librte_graph/Makefile | 1 + lib/librte_graph/graph_debug.c | 25 ++++++++++++++++++++ lib/librte_graph/graph_private.h | 12 ++++++++++ lib/librte_graph/meson.build | 2 +- lib/librte_graph/node.c | 32 ++++++++++++++++++++++++++ lib/librte_graph/rte_graph_version.map | 1 + 6 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 lib/librte_graph/graph_debug.c diff --git a/lib/librte_graph/Makefile b/lib/librte_graph/Makefile index 933d0ee49..2a6d86933 100644 --- a/lib/librte_graph/Makefile +++ b/lib/librte_graph/Makefile @@ -16,6 +16,7 @@ EXPORT_MAP := rte_graph_version.map # all source are stored in SRCS-y SRCS-$(CONFIG_RTE_LIBRTE_GRAPH) += node.c SRCS-$(CONFIG_RTE_LIBRTE_GRAPH) += graph.c +SRCS-$(CONFIG_RTE_LIBRTE_GRAPH) += graph_debug.c # install header files SYMLINK-$(CONFIG_RTE_LIBRTE_GRAPH)-include += rte_graph.h diff --git a/lib/librte_graph/graph_debug.c b/lib/librte_graph/graph_debug.c new file mode 100644 index 000000000..75238e7ca --- /dev/null +++ b/lib/librte_graph/graph_debug.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(C) 2020 Marvell International Ltd. + */ + +#include +#include + +#include "graph_private.h" + +void +node_dump(FILE *f, struct node *n) +{ + rte_edge_t i; + + fprintf(f, "node <%s>\n", n->name); + fprintf(f, " id=%" PRIu32 "\n", n->id); + fprintf(f, " flags=0x%" PRIx64 "\n", n->flags); + fprintf(f, " addr=%p\n", n); + fprintf(f, " process=%p\n", n->process); + fprintf(f, " nb_edges=%d\n", n->nb_edges); + + for (i = 0; i < n->nb_edges; i++) + fprintf(f, " edge[%d] <%s>\n", i, n->next_nodes[i]); +} + diff --git a/lib/librte_graph/graph_private.h b/lib/librte_graph/graph_private.h index 7ed6d01b6..6db04cee7 100644 --- a/lib/librte_graph/graph_private.h +++ b/lib/librte_graph/graph_private.h @@ -82,4 +82,16 @@ void graph_spinlock_lock(void); */ void graph_spinlock_unlock(void); +/** + * @internal + * + * Dump internal node object data. + * + * @param f + * FILE pointer to dump the info. + * @param g + * Pointer to the internal node object. + */ +void node_dump(FILE *f, struct node *n); + #endif /* _RTE_GRAPH_PRIVATE_H_ */ diff --git a/lib/librte_graph/meson.build b/lib/librte_graph/meson.build index 5754ac23b..01512182f 100644 --- a/lib/librte_graph/meson.build +++ b/lib/librte_graph/meson.build @@ -4,7 +4,7 @@ name = 'graph' -sources = files('node.c', 'graph.c') +sources = files('node.c', 'graph.c', 'graph_debug.c') headers = files('rte_graph.h') allow_experimental_apis = true diff --git a/lib/librte_graph/node.c b/lib/librte_graph/node.c index 392e534a9..0652d40c2 100644 --- a/lib/librte_graph/node.c +++ b/lib/librte_graph/node.c @@ -377,6 +377,38 @@ rte_node_edge_get(rte_node_t id, char *next_nodes[]) return rc; } +static void +node_scan_dump(FILE *f, rte_node_t id, bool all) +{ + struct node *node; + + RTE_ASSERT(f != NULL); + NODE_ID_CHECK(id); + + STAILQ_FOREACH(node, &node_list, next) { + if (all == true) { + node_dump(f, node); + } else if (node->id == id) { + node_dump(f, node); + return; + } + } +fail: + return; +} + +void +rte_node_dump(FILE *f, rte_node_t id) +{ + node_scan_dump(f, id, false); +} + +void +rte_node_list_dump(FILE *f) +{ + node_scan_dump(f, 0, true); +} + rte_node_t rte_node_max_count(void) { diff --git a/lib/librte_graph/rte_graph_version.map b/lib/librte_graph/rte_graph_version.map index 412386356..f2c2139c5 100644 --- a/lib/librte_graph/rte_graph_version.map +++ b/lib/librte_graph/rte_graph_version.map @@ -4,6 +4,7 @@ EXPERIMENTAL { __rte_node_register; rte_node_clone; + rte_node_dump; rte_node_edge_count; rte_node_edge_get; rte_node_edge_shrink; -- 2.25.1