From patchwork Sun Apr 5 08:55:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerin Jacob Kollanukkaran X-Patchwork-Id: 67832 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 16EC4A0577; Sun, 5 Apr 2020 10:58:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9AE321C027; Sun, 5 Apr 2020 10:56:50 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id A4A542B83 for ; Sun, 5 Apr 2020 10:56:48 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0358uTei029756; Sun, 5 Apr 2020 01:56:46 -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=9iPEMZ0gD7R1iI5szCcy4loSTM+k615dYEk8h7iP8Y8=; b=ereAQcfgAip9xQBewEnSOmkm16BtsQx0KBaKzdHgWiW8aj3qgN63EvPBXCYzuBH2DJpI 0/pVYbODRCnvYdFGsitT1VDgNY/4MntTkMlRBsfm2mpJY00EvTkvsuv30BkQBlBOYmat YZ+aTCXoKe1ZaixDXkXCSorQM8xQeJOUx1MoqQRc3+KfV/LcdpnzxzvGQ+wU3t9gZJcI j4d5EvWDMmGRE5FgcdtpDLI598G8MOO6yGhgoavUGXfekyMx6LExeMzvvDPNDiCGcmj3 ktOuHD53nrOLp+O2g5qE4sIIzNjmy80qv6kgt6VcjHGJ6YEHLPR1xmRIrVRJq3NbZMyG Ww== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0a-0016f401.pphosted.com with ESMTP id 306qkqtmqn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Sun, 05 Apr 2020 01:56:46 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 5 Apr 2020 01:56:45 -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; Sun, 5 Apr 2020 01:56:45 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 796DF3F703F; Sun, 5 Apr 2020 01:56:42 -0700 (PDT) From: To: Jerin Jacob , Kiran Kumar K CC: , , , , , , , Date: Sun, 5 Apr 2020 14:25:54 +0530 Message-ID: <20200405085613.1336841-11-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200405085613.1336841-1-jerinj@marvell.com> References: <20200331192945.2466880-1-jerinj@marvell.com> <20200405085613.1336841-1-jerinj@marvell.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138, 18.0.676 definitions=2020-04-05_01:2020-04-03, 2020-04-05 signatures=0 Subject: [dpdk-dev] [PATCH v4 10/29] graph: implement 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 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 Signed-off-by: Kiran Kumar K Signed-off-by: Pavan Nikhilesh Signed-off-by: Nithin Dabilpuram --- 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 e0c0b71a7..e96363777 100644 --- a/lib/librte_graph/graph.c +++ b/lib/librte_graph/graph.c @@ -527,6 +527,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;