MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_graph_create

Function rte_graph_create

dpdk/lib/graph/graph.c:382–484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382rte_graph_t
383rte_graph_create(const char *name, struct rte_graph_param *prm)
384{
385 rte_node_t src_node_count;
386 struct graph *graph;
387 const char *pattern;
388 uint16_t i;
389
390 graph_spinlock_lock();
391
392 /* Check arguments sanity */
393 if (prm == NULL)
394 SET_ERR_JMP(EINVAL, fail, "Param should not be NULL");
395
396 if (name == NULL)
397 SET_ERR_JMP(EINVAL, fail, "Graph name should not be NULL");
398
399 /* Check for existence of duplicate graph */
400 STAILQ_FOREACH(graph, &graph_list, next)
401 if (strncmp(name, graph->name, RTE_GRAPH_NAMESIZE) == 0)
402 SET_ERR_JMP(EEXIST, fail, "Found duplicate graph %s",
403 name);
404
405 /* Create graph object */
406 graph = calloc(1, sizeof(*graph));
407 if (graph == NULL)
408 SET_ERR_JMP(ENOMEM, fail, "Failed to calloc graph object");
409
410 /* Initialize the graph object */
411 STAILQ_INIT(&graph->node_list);
412 if (rte_strscpy(graph->name, name, RTE_GRAPH_NAMESIZE) < 0)
413 SET_ERR_JMP(E2BIG, free, "Too big name=%s", name);
414
415 /* Expand node pattern and add the nodes to the graph */
416 for (i = 0; i < prm->nb_node_patterns; i++) {
417 pattern = prm->node_patterns[i];
418 if (expand_pattern_to_node(graph, pattern))
419 goto graph_cleanup;
420 }
421
422 /* Go over all the nodes edges and add them to the graph */
423 if (graph_node_edges_add(graph))
424 goto graph_cleanup;
425
426 /* Update adjacency list of all nodes in the graph */
427 if (graph_adjacency_list_update(graph))
428 goto graph_cleanup;
429
430 /* Make sure at least a source node present in the graph */
431 src_node_count = graph_src_nodes_count(graph);
432 if (src_node_count == 0)
433 goto graph_cleanup;
434
435 /* Make sure no node is pointing to source node */
436 if (graph_node_has_edge_to_src_node(graph))
437 goto graph_cleanup;
438
439 /* Don't allow node has loop to self */

Callers 6

graph_initFunction · 0.85
test_create_graphFunction · 0.85
test_graph_id_collisionsFunction · 0.85
l3fwd_pattern_configureFunction · 0.85
graph_config_rtcFunction · 0.85

Calls 15

graph_spinlock_lockFunction · 0.85
strncmpFunction · 0.85
callocFunction · 0.85
rte_strscpyFunction · 0.85
expand_pattern_to_nodeFunction · 0.85
graph_node_edges_addFunction · 0.85
graph_src_nodes_countFunction · 0.85
graph_node_has_loop_edgeFunction · 0.85
graph_has_isolated_nodeFunction · 0.85
graph_pcap_enableFunction · 0.85

Tested by 3

graph_initFunction · 0.68
test_create_graphFunction · 0.68
test_graph_id_collisionsFunction · 0.68