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 DC4A9A057C; Thu, 26 Mar 2020 17:57:19 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 844C31C08C; Thu, 26 Mar 2020 17:56:47 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id 08BC61C07D for ; Thu, 26 Mar 2020 17:56:45 +0100 (CET) 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 02QGj7pK002884; Thu, 26 Mar 2020 09:56:44 -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=Y1+qTGVCiCscd2KEYUI2pWFOW3bNPKD1+GImbkk9BOI=; b=WqGjOdnxjE7hFb5qy+Bp1b9raoxyi2KX8kE7T16XRD5tjK+Twhu+5PcnzsPlmWq7onoI flHMhQ+GEeneexuTk1ZHKrrsYo0KckX22GLrlzGULVzykcngEX/2Ywr93RBcqVQgChmE o+zmjePXPgmahIuIO1fBDwqDiDvjY9pGBc38W1eSlegY9DNbigjK5wjnJkbfFEvNQkvR nbAetVeLDzLN69omkuLG9Or3QM1N5CZ4SYzd8WoA/04LGDWCY3SJduICm9zKIR4626lv /K4Fnh4f587F03JClmgUtftMMmCKHNXpQ0f4dybHMMrJQ2nvH64Bq5Z3lsuuldq6Vrq6 3w== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpcvu2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 09:56:44 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 09:56:42 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 09:56:42 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id EA2753F7040; Thu, 26 Mar 2020 09:56:39 -0700 (PDT) From: To: Jerin Jacob , Kiran Kumar K CC: , , , , , , Date: Thu, 26 Mar 2020 22:26:20 +0530 Message-ID: <20200326165644.866053-5-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200326165644.866053-1-jerinj@marvell.com> References: <20200318213551.3489504-1-jerinj@marvell.com> <20200326165644.866053-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.645 definitions=2020-03-26_08:2020-03-26, 2020-03-26 signatures=0 Subject: [dpdk-dev] [PATCH v2 04/28] 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 --- 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 8de857889..2f9c2ea4c 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