[dpdk-dev] [PATCH v5 10/29] graph: implement debug routines

jerinj at marvell.com jerinj at marvell.com
Sat Apr 11 16:14:09 CEST 2020


From: Jerin Jacob <jerinj at marvell.com>

Adding implementation for graph specific API to dump the
Graph information to a file. This API will dump detailed internal
info about node objects and graph objects.

Signed-off-by: Jerin Jacob <jerinj at marvell.com>
Signed-off-by: Kiran Kumar K <kirankumark at marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula at marvell.com>
Signed-off-by: Nithin Dabilpuram <ndabilpuram at marvell.com>
---
 lib/librte_graph/graph.c               | 31 ++++++++++++++
 lib/librte_graph/graph_debug.c         | 59 ++++++++++++++++++++++++++
 lib/librte_graph/graph_private.h       | 13 ++++++
 lib/librte_graph/rte_graph_version.map |  2 +
 4 files changed, 105 insertions(+)

diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c
index 61e212e03..e811a7b38 100644
--- a/lib/librte_graph/graph.c
+++ b/lib/librte_graph/graph.c
@@ -525,6 +525,37 @@ rte_graph_export(const char *name, FILE *f)
 	return -rc;
 }
 
+static void
+graph_scan_dump(FILE *f, rte_graph_t id, bool all)
+{
+	struct graph *graph;
+
+	RTE_VERIFY(f);
+	GRAPH_ID_CHECK(id);
+
+	STAILQ_FOREACH(graph, &graph_list, next) {
+		if (all == true) {
+			graph_dump(f, graph);
+		} else if (graph->id == id) {
+			graph_dump(f, graph);
+			return;
+		}
+	}
+fail:
+	return;
+}
+
+void
+rte_graph_dump(FILE *f, rte_graph_t id)
+{
+	graph_scan_dump(f, id, false);
+}
+
+void
+rte_graph_list_dump(FILE *f)
+{
+	graph_scan_dump(f, 0, true);
+}
 
 rte_graph_t
 rte_graph_max_count(void)
diff --git a/lib/librte_graph/graph_debug.c b/lib/librte_graph/graph_debug.c
index 75238e7ca..f8aea16ac 100644
--- a/lib/librte_graph/graph_debug.c
+++ b/lib/librte_graph/graph_debug.c
@@ -7,6 +7,26 @@
 
 #include "graph_private.h"
 
+void
+graph_dump(FILE *f, struct graph *g)
+{
+	struct graph_node *graph_node;
+	rte_edge_t i = 0;
+
+	fprintf(f, "graph <%s>\n", g->name);
+	fprintf(f, "  id=%" PRIu32 "\n", g->id);
+	fprintf(f, "  cir_start=%" PRIu32 "\n", g->cir_start);
+	fprintf(f, "  cir_mask=%" PRIu32 "\n", g->cir_mask);
+	fprintf(f, "  addr=%p\n", g);
+	fprintf(f, "  graph=%p\n", g->graph);
+	fprintf(f, "  mem_sz=%zu\n", g->mem_sz);
+	fprintf(f, "  node_count=%" PRIu32 "\n", g->node_count);
+	fprintf(f, "  src_node_count=%" PRIu32 "\n", g->src_node_count);
+
+	STAILQ_FOREACH(graph_node, &g->node_list, next)
+		fprintf(f, "     node[%d] <%s>\n", i++, graph_node->node->name);
+}
+
 void
 node_dump(FILE *f, struct node *n)
 {
@@ -23,3 +43,42 @@ node_dump(FILE *f, struct node *n)
 		fprintf(f, "     edge[%d] <%s>\n", i, n->next_nodes[i]);
 }
 
+void
+rte_graph_obj_dump(FILE *f, struct rte_graph *g, bool all)
+{
+	rte_node_t count;
+	rte_graph_off_t off;
+	struct rte_node *n;
+	rte_edge_t i;
+
+	fprintf(f, "graph <%s> @ %p\n", g->name, g);
+	fprintf(f, "  id=%" PRIu32 "\n", g->id);
+	fprintf(f, "  head=%" PRId32 "\n", (int32_t)g->head);
+	fprintf(f, "  tail=%" PRId32 "\n", (int32_t)g->tail);
+	fprintf(f, "  cir_mask=0x%" PRIx32 "\n", g->cir_mask);
+	fprintf(f, "  nb_nodes=%" PRId32 "\n", g->nb_nodes);
+	fprintf(f, "  socket=%d\n", g->socket);
+	fprintf(f, "  fence=0x%" PRIx64 "\n", g->fence);
+	fprintf(f, "  nodes_start=0x%" PRIx32 "\n", g->nodes_start);
+	fprintf(f, "  cir_start=%p\n", g->cir_start);
+
+	rte_graph_foreach_node(count, off, g, n) {
+		if (!all && n->idx == 0)
+			continue;
+		fprintf(f, "     node[%d] <%s>\n", count, n->name);
+		fprintf(f, "       fence=0x%" PRIx64 "\n", n->fence);
+		fprintf(f, "       objs=%p\n", n->objs);
+		fprintf(f, "       process=%p\n", n->process);
+		fprintf(f, "       id=0x%" PRIx32 "\n", n->id);
+		fprintf(f, "       offset=0x%" PRIx32 "\n", n->off);
+		fprintf(f, "       nb_edges=%" PRId32 "\n", n->nb_edges);
+		fprintf(f, "       realloc_count=%d\n", n->realloc_count);
+		fprintf(f, "       size=%d\n", n->size);
+		fprintf(f, "       idx=%d\n", n->idx);
+		fprintf(f, "       total_objs=%" PRId64 "\n", n->total_objs);
+		fprintf(f, "       total_calls=%" PRId64 "\n", n->total_calls);
+		for (i = 0; i < n->nb_edges; i++)
+			fprintf(f, "          edge[%d] <%s>\n", i,
+				n->nodes[i]->name);
+	}
+}
diff --git a/lib/librte_graph/graph_private.h b/lib/librte_graph/graph_private.h
index 7fce52e00..f9a85c892 100644
--- a/lib/librte_graph/graph_private.h
+++ b/lib/librte_graph/graph_private.h
@@ -319,6 +319,19 @@ struct rte_node *graph_node_id_to_ptr(const struct rte_graph *graph,
 struct rte_node *graph_node_name_to_ptr(const struct rte_graph *graph,
 					const char *node_name);
 
+/* Debug functions */
+/**
+ * @internal
+ *
+ * Dump internal graph object data.
+ *
+ * @param f
+ *   FILE pointer to dump the data.
+ * @param g
+ *   Pointer to the internal graph object.
+ */
+void graph_dump(FILE *f, struct graph *g);
+
 /**
  * @internal
  *
diff --git a/lib/librte_graph/rte_graph_version.map b/lib/librte_graph/rte_graph_version.map
index 2797be044..851f4772e 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_dump;
 	rte_graph_export;
 	rte_graph_from_name;
 	rte_graph_id_to_name;
@@ -14,6 +15,7 @@ EXPERIMENTAL {
 	rte_graph_max_count;
 	rte_graph_node_get;
 	rte_graph_node_get_by_name;
+	rte_graph_obj_dump;
 
 	rte_node_clone;
 	rte_node_dump;
-- 
2.25.1



More information about the dev mailing list