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 E5919A057D; Wed, 18 Mar 2020 22:37:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8B4451C0BC; Wed, 18 Mar 2020 22:36:02 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 6B13C1BF82 for ; Wed, 18 Mar 2020 22:36:01 +0100 (CET) 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 02ILV0Z6003373; Wed, 18 Mar 2020 14:35:59 -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=65DBIT1s1fgfNLXPCW8K6SsQf9AOyhoAlW8Q3f8U+LA=; b=xraHDoVeoPVZfFZudppr2bkW37JKJ4OK+EL3USSQqsivuSvQmOA+J3pX7iAYuDAg66IO 172J4cGT6y3Egw7FkG7qpwgrtvbFqzVoXX0+8+6sciJJM+0Sivwn2PcVYBHD3R4FeYnf QXnMm78a3HVaaATKl7X4p3PQIlNmWcA/D/ymSx0ZTpu/yeNd2TL8PWmqxQzni9w7TW1G Jd69dkwPEGN2CWBxiEgqz2mXR9Nw2HFLeGqOHxO6brKJXKfjBKHe6+56lVSXFTgYR8ad ty8677qQGuCyfdBrmAB9ND0cfy7LDX5w5reZ6I6JbZnivvnfVkGRFWx/TtRfHYbVyiXh lw== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2yu8pqmrat-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 18 Mar 2020 14:35:59 -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; Wed, 18 Mar 2020 14:35:58 -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; Wed, 18 Mar 2020 14:35:58 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 8474B3F7040; Wed, 18 Mar 2020 14:35:55 -0700 (PDT) From: To: Jerin Jacob , Kiran Kumar K CC: , , , , , , Date: Thu, 19 Mar 2020 03:05:35 +0530 Message-ID: <20200318213551.3489504-11-jerinj@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200318213551.3489504-1-jerinj@marvell.com> References: <20200318213551.3489504-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-18_07:2020-03-18, 2020-03-18 signatures=0 Subject: [dpdk-dev] [PATCH v1 10/26] 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 --- 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 ad58673be..cc1e523d9 100644 --- a/lib/librte_graph/graph.c +++ b/lib/librte_graph/graph.c @@ -528,6 +528,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 051fad53a..397247797 100644 --- a/lib/librte_graph/graph_private.h +++ b/lib/librte_graph/graph_private.h @@ -318,6 +318,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