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 4F1E8A057C; Thu, 26 Mar 2020 17:58:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6707D1C0CB; Thu, 26 Mar 2020 17:57:04 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id EC2F81C0CA for ; Thu, 26 Mar 2020 17:57:03 +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 02QGj5Ka002868; Thu, 26 Mar 2020 09:57:02 -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=bedaZ2PTWBAsjTDdy+r7ZCftyqHXkBCYnUsYuLM7Bzs=; b=JK+4edkHIfcgfvCpKDuinDyz95ks/iomAbaNWUZM7+BfvyzuSb/uexoyQ6DK0xeLAJ3D LJy/33Kp4aBLOHO+XyeGAap68gvryejRvSjRm+bl1zCEX4pk/OMe7sqmpUj2zqHGZ2hP oDCmkHipqdi5OpA+Ef8lO84PcyGJBr7WENNbTySEdY5T3G7YiQp0KLsaAOzcA2G5WRtY vJNDCp+Hphc/VFvLfA21/nSwC5jnL8Tx0rLHL0S13mL42WjYXeibPMBQhkvAHbV9pJXT wDv9CAyrNKAlXeG8GWhvnkwM7VBrUhnC0dMHsd2wM5n3YGf6hneBAesOor9CUBRlGCa5 qA== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0b-0016f401.pphosted.com with ESMTP id 300bpcvu3t-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Mar 2020 09:57:02 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) 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:59 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 26 Mar 2020 09:56:59 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 26 Mar 2020 09:56:58 -0700 Received: from jerin-lab.marvell.com (jerin-lab.marvell.com [10.28.34.14]) by maili.marvell.com (Postfix) with ESMTP id 5F41E3F7040; Thu, 26 Mar 2020 09:56:56 -0700 (PDT) From: To: Jerin Jacob , Kiran Kumar K , Anatoly Burakov CC: , , , , , , Date: Thu, 26 Mar 2020 22:26:24 +0530 Message-ID: <20200326165644.866053-9-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 08/28] graph: implement graph operation APIs 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 support for graph specific API implementation like Graph lookup to get graph object, retrieving graph ID >From name and graph name from ID. Signed-off-by: Jerin Jacob Signed-off-by: Kiran Kumar K Signed-off-by: Pavan Nikhilesh --- lib/librte_graph/graph.c | 131 +++++++++++++++++++++++++ lib/librte_graph/rte_graph_version.map | 8 ++ 2 files changed, 139 insertions(+) diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c index dc373231e..7c6a7897d 100644 --- a/lib/librte_graph/graph.c +++ b/lib/librte_graph/graph.c @@ -210,6 +210,54 @@ graph_node_fini(struct graph *graph) graph_node->node->name)); } +static struct rte_graph * +graph_mem_fixup_node_ctx(struct rte_graph *graph) +{ + struct rte_node *node; + struct node *node_db; + rte_graph_off_t off; + rte_node_t count; + const char *name; + + rte_graph_foreach_node(count, off, graph, node) { + if (node->parent_id == RTE_NODE_ID_INVALID) /* Static node */ + name = node->name; + else /* Cloned node */ + name = node->parent; + + node_db = node_from_name(name); + if (node_db == NULL) + SET_ERR_JMP(ENOLINK, fail, "Node %s not found", name); + node->process = node_db->process; + } + + return graph; +fail: + return NULL; +} + +static struct rte_graph * +graph_mem_fixup_secondray(struct rte_graph *graph) +{ + if (graph == NULL || rte_eal_process_type() == RTE_PROC_PRIMARY) + return graph; + + return graph_mem_fixup_node_ctx(graph); +} + +struct rte_graph * +rte_graph_lookup(const char *name) +{ + const struct rte_memzone *mz; + struct rte_graph *rc = NULL; + + mz = rte_memzone_lookup(name); + if (mz) + rc = mz->addr; + + return graph_mem_fixup_secondray(rc); +} + rte_graph_t rte_graph_create(const char *name, struct rte_graph_param *prm) { @@ -341,6 +389,76 @@ rte_graph_destroy(const char *graph_name) return rc; } +rte_graph_t +rte_graph_from_name(const char *name) +{ + struct graph *graph; + + STAILQ_FOREACH(graph, &graph_list, next) + if (strncmp(graph->name, name, RTE_GRAPH_NAMESIZE) == 0) + return graph->id; + + return RTE_GRAPH_ID_INVALID; +} + +char * +rte_graph_id_to_name(rte_graph_t id) +{ + struct graph *graph; + + GRAPH_ID_CHECK(id); + STAILQ_FOREACH(graph, &graph_list, next) + if (graph->id == id) + return graph->name; + +fail: + return NULL; +} + +struct rte_node * +rte_graph_node_get(rte_graph_t gid, uint32_t nid) +{ + struct rte_node *node; + struct graph *graph; + rte_graph_off_t off; + rte_node_t count; + + GRAPH_ID_CHECK(gid); + STAILQ_FOREACH(graph, &graph_list, next) + if (graph->id == gid) { + rte_graph_foreach_node(count, off, graph->graph, + node) { + if (node->id == nid) + return node; + } + break; + } +fail: + return NULL; +} + +struct rte_node * +rte_graph_node_get_by_name(const char *graph_name, const char *node_name) +{ + struct rte_node *node; + struct graph *graph; + rte_graph_off_t off; + rte_node_t count; + + STAILQ_FOREACH(graph, &graph_list, next) + if (!strncmp(graph->name, graph_name, RTE_GRAPH_NAMESIZE)) { + rte_graph_foreach_node(count, off, graph->graph, + node) { + if (!strncmp(node->name, node_name, + RTE_NODE_NAMESIZE)) + return node; + } + break; + } + + return NULL; +} + void __rte_noinline __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node) { @@ -355,3 +473,16 @@ __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node) node->size = size; node->realloc_count++; } + +rte_graph_t +rte_graph_max_count(void) +{ + return graph_id; +} + +RTE_INIT(rte_graph_init_log) +{ + rte_graph_logtype = rte_log_register("lib.graph"); + if (rte_graph_logtype >= 0) + rte_log_set_level(rte_graph_logtype, RTE_LOG_INFO); +} diff --git a/lib/librte_graph/rte_graph_version.map b/lib/librte_graph/rte_graph_version.map index dcbd78c02..5a2b13293 100644 --- a/lib/librte_graph/rte_graph_version.map +++ b/lib/librte_graph/rte_graph_version.map @@ -6,6 +6,14 @@ EXPERIMENTAL { rte_graph_create; rte_graph_destroy; + rte_graph_from_name; + rte_graph_id_to_name; + rte_graph_lookup; + rte_graph_list_dump; + rte_graph_max_count; + rte_graph_node_get; + rte_graph_node_get_by_name; + rte_node_clone; rte_node_dump; rte_node_edge_count; -- 2.25.1