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

Function graph_clone

dpdk/lib/graph/graph.c:523–599  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

521}
522
523static rte_graph_t
524graph_clone(struct graph *parent_graph, const char *name, struct rte_graph_param *prm)
525{
526 struct graph_node *graph_node;
527 struct graph *graph;
528
529 graph_spinlock_lock();
530
531 /* Don't allow to clone a node from a cloned graph */
532 if (parent_graph->parent_id != RTE_GRAPH_ID_INVALID)
533 SET_ERR_JMP(EEXIST, fail, "A cloned graph is not allowed to be cloned");
534
535 /* Create graph object */
536 graph = calloc(1, sizeof(*graph));
537 if (graph == NULL)
538 SET_ERR_JMP(ENOMEM, fail, "Failed to calloc cloned graph object");
539
540 /* Naming ceremony of the new graph. name is node->name + "-" + name */
541 if (clone_name(graph->name, parent_graph->name, name))
542 goto free;
543
544 /* Check for existence of duplicate graph */
545 if (rte_graph_from_name(graph->name) != RTE_GRAPH_ID_INVALID)
546 SET_ERR_JMP(EEXIST, free, "Found duplicate graph %s",
547 graph->name);
548
549 /* Clone nodes from parent graph firstly */
550 STAILQ_INIT(&graph->node_list);
551 STAILQ_FOREACH(graph_node, &parent_graph->node_list, next) {
552 if (graph_node_add(graph, graph_node->node))
553 goto graph_cleanup;
554 }
555
556 /* Just update adjacency list of all nodes in the graph */
557 if (graph_adjacency_list_update(graph))
558 goto graph_cleanup;
559
560 /* Initialize the graph object */
561 graph->src_node_count = parent_graph->src_node_count;
562 graph->node_count = parent_graph->node_count;
563 graph->parent_id = parent_graph->id;
564 graph->lcore_id = parent_graph->lcore_id;
565 graph->socket = parent_graph->socket;
566 graph->id = graph_next_free_id();
567
568 /* Allocate the Graph fast path memory and populate the data */
569 if (graph_fp_mem_create(graph))
570 goto graph_cleanup;
571
572 /* Clone the graph model */
573 graph->graph->model = parent_graph->graph->model;
574
575 /* Create the graph schedule work queue */
576 if (rte_graph_worker_model_get(graph->graph) == RTE_GRAPH_MODEL_MCORE_DISPATCH &&
577 graph_sched_wq_create(graph, parent_graph, prm))
578 goto graph_mem_destroy;
579
580 /* Call init() of the all the nodes in the graph */

Callers 1

rte_graph_cloneFunction · 0.85

Calls 15

graph_spinlock_lockFunction · 0.85
callocFunction · 0.85
clone_nameFunction · 0.85
rte_graph_from_nameFunction · 0.85
graph_node_addFunction · 0.85
graph_next_free_idFunction · 0.85
graph_fp_mem_createFunction · 0.85
graph_sched_wq_createFunction · 0.85
graph_node_initFunction · 0.85
graph_insert_orderedFunction · 0.85

Tested by

no test coverage detected