graph: implement debug routines
authorJerin Jacob <jerinj@marvell.com>
Sat, 11 Apr 2020 14:14:09 +0000 (19:44 +0530)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 5 May 2020 21:31:47 +0000 (23:31 +0200)
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@marvell.com>
Signed-off-by: Kiran Kumar K <kirankumark@marvell.com>
Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Signed-off-by: Nithin Dabilpuram <ndabilpuram@marvell.com>
lib/librte_graph/graph.c
lib/librte_graph/graph_debug.c
lib/librte_graph/graph_private.h
lib/librte_graph/rte_graph_version.map

index 61e212e..e811a7b 100644 (file)
@@ -525,6 +525,37 @@ end:
        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)
index 3374e04..f8aea16 100644 (file)
@@ -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)
 {
@@ -22,3 +42,43 @@ node_dump(FILE *f, struct node *n)
        for (i = 0; i < n->nb_edges; i++)
                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);
+       }
+}
index 7fce52e..f9a85c8 100644 (file)
@@ -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
  *
index 2797be0..851f477 100644 (file)
@@ -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;