Lines Matching defs:graph

24 static struct graph *
27 struct graph *graph;
28 STAILQ_FOREACH(graph, &graph_list, next) {
29 if (graph->id == id)
30 return graph;
39 struct graph *graph;
42 STAILQ_FOREACH(graph, &graph_list, next) {
43 if (id < graph->id)
45 id = graph->id + 1;
52 graph_insert_ordered(struct graph *graph)
54 struct graph *after, *g;
58 if (g->id < graph->id)
60 else if (g->id > graph->id)
64 STAILQ_INSERT_HEAD(&graph_list, graph, next);
66 STAILQ_INSERT_AFTER(&graph_list, after, graph, next);
95 graph_node_add(struct graph *graph, struct node *node)
101 STAILQ_FOREACH(graph_node, &graph->node_list, next)
106 /* Allocate new graph node object */
114 /* Initialize the graph node */
117 /* Add to graph node list */
118 STAILQ_INSERT_TAIL(&graph->node_list, graph_node, next);
127 node_to_graph_node(struct graph *graph, struct node *node)
131 STAILQ_FOREACH(graph_node, &graph->node_list, next)
141 graph_node_edges_add(struct graph *graph)
148 STAILQ_FOREACH(graph_node, &graph->node_list, next) {
155 if (graph_node_add(graph, adjacency))
165 graph_adjacency_list_update(struct graph *graph)
172 STAILQ_FOREACH(graph_node, &graph->node_list, next) {
179 tmp = node_to_graph_node(graph, adjacency);
192 expand_pattern_to_node(struct graph *graph, const char *pattern)
201 if (graph_node_add(graph, node))
215 graph_cleanup(struct graph *graph)
219 while (!STAILQ_EMPTY(&graph->node_list)) {
220 graph_node = STAILQ_FIRST(&graph->node_list);
221 STAILQ_REMOVE_HEAD(&graph->node_list, next);
227 graph_node_init(struct graph *graph)
233 STAILQ_FOREACH(graph_node, &graph->node_list, next) {
237 graph->graph,
238 graph_node_name_to_ptr(graph->graph, name));
251 graph_node_fini(struct graph *graph)
255 STAILQ_FOREACH(graph_node, &graph->node_list, next)
258 graph->graph,
259 graph_node_name_to_ptr(graph->graph,
264 graph_mem_fixup_node_ctx(struct rte_graph *graph)
272 rte_graph_foreach_node(count, off, graph, node) {
282 if (graph->pcap_enable) {
289 return graph;
295 graph_mem_fixup_secondary(struct rte_graph *graph)
297 if (graph == NULL || rte_eal_process_type() == RTE_PROC_PRIMARY)
298 return graph;
300 if (graph_pcap_file_open(graph->pcap_filename) || graph_pcap_mp_init())
301 graph_pcap_exit(graph);
303 return graph_mem_fixup_node_ctx(graph);
307 graph_src_node_avail(struct graph *graph)
311 STAILQ_FOREACH(graph_node, &graph->node_list, next)
314 graph->lcore_id == graph_node->node->lcore_id))
323 struct graph *graph;
330 STAILQ_FOREACH(graph, &graph_list, next)
331 if (graph->id == id)
334 if (graph->graph->model != RTE_GRAPH_MODEL_MCORE_DISPATCH)
337 graph->lcore_id = lcore;
338 graph->graph->dispatch.lcore_id = graph->lcore_id;
339 graph->socket = rte_lcore_to_socket_id(lcore);
342 if (!graph_src_node_avail(graph))
343 graph->graph->head = 0;
354 struct graph *graph;
358 STAILQ_FOREACH(graph, &graph_list, next)
359 if (graph->id == id)
362 graph->lcore_id = RTE_MAX_LCORE;
363 graph->graph->dispatch.lcore_id = RTE_MAX_LCORE;
386 struct graph *graph;
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",
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");
410 /* Initialize the graph object */
411 STAILQ_INIT(&graph->node_list);
412 if (rte_strscpy(graph->name, name, RTE_GRAPH_NAMESIZE) < 0)
415 /* Expand node pattern and add the nodes to the graph */
418 if (expand_pattern_to_node(graph, pattern))
422 /* Go over all the nodes edges and add them to the graph */
423 if (graph_node_edges_add(graph))
426 /* Update adjacency list of all nodes in the graph */
427 if (graph_adjacency_list_update(graph))
430 /* Make sure at least a source node present in the graph */
431 src_node_count = graph_src_nodes_count(graph);
436 if (graph_node_has_edge_to_src_node(graph))
440 if (graph_node_has_loop_edge(graph))
443 /* Do BFS from src nodes on the graph to find isolated nodes */
444 if (graph_has_isolated_node(graph))
450 /* Initialize graph object */
451 graph->socket = prm->socket_id;
452 graph->src_node_count = src_node_count;
453 graph->node_count = graph_nodes_count(graph);
454 graph->id = graph_next_free_id();
455 graph->parent_id = RTE_GRAPH_ID_INVALID;
456 graph->lcore_id = RTE_MAX_LCORE;
457 graph->num_pkt_to_capture = prm->num_pkt_to_capture;
459 rte_strscpy(graph->pcap_filename, prm->pcap_filename, RTE_GRAPH_PCAP_FILE_SZ);
462 if (graph_fp_mem_create(graph))
465 /* Call init() of the all the nodes in the graph */
466 if (graph_node_init(graph))
469 /* All good, Lets add the graph to the list */
470 graph_insert_ordered(graph);
473 return graph->id;
476 graph_fp_mem_destroy(graph);
478 graph_cleanup(graph);
480 free(graph);
489 struct graph *graph, *tmp;
494 graph = STAILQ_FIRST(&graph_list);
495 while (graph != NULL) {
496 tmp = STAILQ_NEXT(graph, next);
497 if (graph->id == id) {
499 if (rte_graph_worker_model_get(graph->graph) ==
501 graph_sched_wq_destroy(graph);
503 /* Call fini() of the all the nodes in the graph */
504 graph_node_fini(graph);
505 /* Destroy graph fast path memory */
506 rc = graph_fp_mem_destroy(graph);
509 graph->name);
511 graph_cleanup(graph);
512 STAILQ_REMOVE(&graph_list, graph, graph, next);
513 free(graph);
516 graph = tmp;
524 graph_clone(struct graph *parent_graph, const char *name, struct rte_graph_param *prm)
527 struct graph *graph;
531 /* Don't allow to clone a node from a cloned graph */
533 SET_ERR_JMP(EEXIST, fail, "A cloned graph is not allowed to be cloned");
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");
540 /* Naming ceremony of the new graph. name is node->name + "-" + name */
541 if (clone_name(graph->name, parent_graph->name, name))
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);
549 /* Clone nodes from parent graph firstly */
550 STAILQ_INIT(&graph->node_list);
552 if (graph_node_add(graph, graph_node->node))
556 /* Just update adjacency list of all nodes in the graph */
557 if (graph_adjacency_list_update(graph))
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();
569 if (graph_fp_mem_create(graph))
572 /* Clone the graph model */
573 graph->graph->model = parent_graph->graph->model;
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))
580 /* Call init() of the all the nodes in the graph */
581 if (graph_node_init(graph))
584 /* All good, Lets add the graph to the list */
585 graph_insert_ordered(graph);
588 return graph->id;
591 graph_fp_mem_destroy(graph);
593 graph_cleanup(graph);
595 free(graph);
604 struct graph *graph;
608 STAILQ_FOREACH(graph, &graph_list, next)
609 if (graph->id == id)
610 return graph_clone(graph, name, prm);
619 struct graph *graph;
621 STAILQ_FOREACH(graph, &graph_list, next)
622 if (strncmp(graph->name, name, RTE_GRAPH_NAMESIZE) == 0)
623 return graph->id;
631 struct graph *graph;
635 STAILQ_FOREACH(graph, &graph_list, next)
636 if (graph->id == id)
637 return graph->name;
647 struct graph *graph;
653 STAILQ_FOREACH(graph, &graph_list, next)
654 if (graph->id == gid) {
655 rte_graph_foreach_node(count, off, graph->graph,
670 struct graph *graph;
674 STAILQ_FOREACH(graph, &graph_list, next)
675 if (!strncmp(graph->name, graph_name, RTE_GRAPH_NAMESIZE)) {
676 rte_graph_foreach_node(count, off, graph->graph,
689 __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node)
697 RTE_CACHE_LINE_SIZE, graph->socket);
704 __rte_node_stream_alloc_size(struct rte_graph *graph, struct rte_node *node,
713 RTE_CACHE_LINE_SIZE, graph->socket);
720 graph_to_dot(FILE *f, struct graph *graph)
727 rc = fprintf(f, "digraph \"%s\" {\n\trankdir=LR;\n", graph->name);
735 STAILQ_FOREACH(graph_node, &graph->node_list, next) {
779 struct graph *graph;
782 STAILQ_FOREACH(graph, &graph_list, next) {
783 if (strncmp(graph->name, name, RTE_GRAPH_NAMESIZE) == 0) {
784 rc = graph_to_dot(f, graph);
795 struct graph *graph;
801 STAILQ_FOREACH(graph, &graph_list, next) {
803 graph_dump(f, graph);
804 } else if (graph->id == id) {
805 graph_dump(f, graph);
828 struct graph *graph;
831 STAILQ_FOREACH(graph, &graph_list, next)