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 35EA1A0597; Wed, 8 Apr 2020 18:57:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F9271C0B7; Wed, 8 Apr 2020 18:57:49 +0200 (CEST) Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) by dpdk.org (Postfix) with ESMTP id 8B8F51C0B3 for ; Wed, 8 Apr 2020 18:57:47 +0200 (CEST) Received: by mail-lf1-f67.google.com with SMTP id k28so5667857lfe.10 for ; Wed, 08 Apr 2020 09:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=x+2meq699UXQgeuPWGNmp5GW9vY7pZBOhtKRwcMEDO0=; b=F8yHDy3qIUkUVZbMCQmcV2RlIAbAnRGKMfC4UMT7/uYgT19uuEbEAaulEmqQNZ7EVv b/nXaDdmKJT43bicapfeyOWH1T/kmQv/n3YdlMi6xPsdpb5/vFyhUlaXhB+Iuu951NT7 dYq7ndzAqyv8cLfmXxzwNdvxL5yHte1X0NDyuxdmCZS4rBm8T4UsesKFZ0GWDVc7sf0q 0Fwiorv/1HCtJorOC/78MHKHcj5evizNLdYS5QxvNjYijV+ZB/yx69IkqOOsqS21hzxq lWbDfRB3gE4/xERzX53/zeN17eBfQl+OPao6lanptcujxLVBNWwvQGN1+Jfsc4/xlWS6 xVwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=x+2meq699UXQgeuPWGNmp5GW9vY7pZBOhtKRwcMEDO0=; b=DZoKgUBNi/ahIfxX2IikuDRm1QmleHDzUOczLyWfsu5pnatgcckgH+8VDFUqBkPNVk PK19ArrzEl8dpssxrHxsa3IVoEMwP7jZ0eomf7OZ24UNNyM5xhWGWByjVv9bJSpGPbr4 Oa11cGHpIvqIuPqw6YadDc/wnk1hMUGB6Hq59lKujhRLLRCZMwlnYIbbex6WGWWp27y4 krZs2YYNGKVPKODPGY2U/reNGYVvjLyUZdbVNmmxF7u/BFoZ5tNUbY0wsw3qmFmKDbcU MuvgPUA/WVhp5eT7+W2g1XXjDJPvYHXhEEcrg9f/P0rnN1Ete+yvDq0df8AujboyfC6W Or+Q== X-Gm-Message-State: AGi0PuZyyLgbUkt/hyMFEserLmUSwGNSxErbNaNFgFgPIwvq5LNGiwou VXHeWM4OFVSFXn2okTQWDufJrFH3ZIw= X-Google-Smtp-Source: APiQypLwsFM8y0wdWY+WSuuFcC13G06SOGqru4rMou/nmbCfCXPbZ5icsImAOOAZs3RUA58l0lZTuQ== X-Received: by 2002:a19:f614:: with SMTP id x20mr5124212lfe.84.1586365065027; Wed, 08 Apr 2020 09:57:45 -0700 (PDT) Received: from [192.168.8.100] (user-5-173-33-152.play-internet.pl. [5.173.33.152]) by smtp.gmail.com with ESMTPSA id n24sm13967507lji.19.2020.04.08.09.57.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Apr 2020 09:57:44 -0700 (PDT) To: dev@dpdk.org References: <20200331192945.2466880-1-jerinj@marvell.com> <20200405085613.1336841-1-jerinj@marvell.com> <20200405085613.1336841-8-jerinj@marvell.com> From: Andrzej Ostruszka Message-ID: <22dda6ca-abca-1514-95c9-ae5ec869add9@semihalf.com> Date: Wed, 8 Apr 2020 18:57:43 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200405085613.1336841-8-jerinj@marvell.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v4 07/29] graph: implement create and destroy 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" On 4/5/20 10:55 AM, jerinj@marvell.com wrote: > From: Jerin Jacob > > Adding graph specific API implementations like graph create > and graph destroy. This detect loops in the graph, > check for isolated nodes and operation to verify the validity of > graph. > > 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 | 320 +++++++++++++++++++++++++ > lib/librte_graph/rte_graph_version.map | 2 + > 2 files changed, 322 insertions(+) > > diff --git a/lib/librte_graph/graph.c b/lib/librte_graph/graph.c > index e1930b7d2..dc373231e 100644 > --- a/lib/librte_graph/graph.c > +++ b/lib/librte_graph/graph.c [...] > +static int > +graph_node_add(struct graph *graph, struct node *node) > +{ > + struct graph_node *graph_node; > + size_t sz; > + > + /* Skip the duplicate nodes */ > + STAILQ_FOREACH(graph_node, &graph->node_list, next) > + if (strncmp(node->name, graph_node->node->name, > + RTE_NODE_NAMESIZE) == 0) Is it not a "deficiency" of a program to attempt to add node twice? If it is, then maybe a warning here? [...] > +rte_graph_t > +rte_graph_create(const char *name, struct rte_graph_param *prm) > +{ > + struct graph *graph; > + const char *pattern; > + uint16_t i; > + > + graph_spinlock_lock(); > + > + /* Check arguments sanity */ > + if (prm == NULL) > + SET_ERR_JMP(EINVAL, fail, "Param should not be NULL"); > + > + if (name == NULL) > + SET_ERR_JMP(EINVAL, fail, "Graph name should not be NULL"); > + > + /* Check for existence of duplicate graph */ > + STAILQ_FOREACH(graph, &graph_list, next) > + if (strncmp(name, graph->name, RTE_GRAPH_NAMESIZE) == 0) > + SET_ERR_JMP(EEXIST, fail, "Found duplicate graph %s", > + name); > + > + /* Create graph object */ > + graph = calloc(1, sizeof(*graph)); > + if (graph == NULL) > + SET_ERR_JMP(ENOMEM, fail, "Failed to calloc graph object"); > + > + /* Initialize the graph object */ > + STAILQ_INIT(&graph->node_list); > + if (rte_strscpy(graph->name, name, RTE_GRAPH_NAMESIZE) < 0) > + SET_ERR_JMP(E2BIG, free, "Too big name=%s", name); > + > + /* Expand node pattern and add the nodes to the graph */ > + for (i = 0; i < prm->nb_node_patterns; i++) { > + pattern = prm->node_patterns[i]; > + if (expand_pattern_to_node(graph, pattern)) > + goto graph_cleanup; > + } > + > + /* Go over all the nodes edges and add them to the graph */ > + if (graph_node_edges_add(graph)) > + goto graph_cleanup; > + > + /* Update adjacency list of all nodes in the graph */ > + if (graph_adjacency_list_update(graph)) > + goto graph_cleanup; > + > + /* Make sure at least a source node present in the graph */ > + if (!graph_src_nodes_count(graph)) > + goto graph_cleanup; > + > + /* Make sure no node is pointing to source node */ > + if (graph_node_has_edge_to_src_node(graph)) > + goto graph_cleanup; > + > + /* Don't allow node has loop to self */ > + if (graph_node_has_loop_edge(graph)) > + goto graph_cleanup; > + > + /* Do BFS from src nodes on the graph to find isolated nodes */ > + if (graph_has_isolated_node(graph)) > + goto graph_cleanup; > + > + /* Initialize graph object */ > + graph->socket = prm->socket_id; > + graph->src_node_count = graph_src_nodes_count(graph); Maybe reuse value of previous call (above)? > + graph->node_count = graph_nodes_count(graph); > + graph->id = graph_id; > + > + /* Allocate the Graph fast path memory and populate the data */ > + if (graph_fp_mem_create(graph)) > + goto graph_cleanup; > + > + /* Call init() of the all the nodes in the graph */ > + if (graph_node_init(graph)) > + goto graph_mem_destroy; > + > + /* All good, Lets add the graph to the list */ > + graph_id++; > + STAILQ_INSERT_TAIL(&graph_list, graph, next); > + > + graph_spinlock_unlock(); > + return graph->id; > + > +graph_mem_destroy: > + graph_fp_mem_destroy(graph); > +graph_cleanup: > + graph_cleanup(graph); > +free: > + free(graph); > +fail: > + graph_spinlock_unlock(); > + return RTE_GRAPH_ID_INVALID; > +} > + With regards Andrzej Ostruszka