doc: add Meson coding style to contributors guide
[dpdk.git] / lib / librte_graph / graph.c
index 61e212e..7224b00 100644 (file)
@@ -18,7 +18,6 @@
 static struct graph_head graph_list = STAILQ_HEAD_INITIALIZER(graph_list);
 static rte_spinlock_t graph_lock = RTE_SPINLOCK_INITIALIZER;
 static rte_graph_t graph_id;
-int rte_graph_logtype;
 
 #define GRAPH_ID_CHECK(id) ID_CHECK(id, graph_id)
 
@@ -473,6 +472,22 @@ __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node)
        node->realloc_count++;
 }
 
+void __rte_noinline
+__rte_node_stream_alloc_size(struct rte_graph *graph, struct rte_node *node,
+                            uint16_t req_size)
+{
+       uint16_t size = node->size;
+
+       RTE_VERIFY(size != UINT16_MAX);
+       /* Allocate double amount of size to avoid immediate realloc */
+       size = RTE_MIN(UINT16_MAX, RTE_MAX(RTE_GRAPH_BURST_SIZE, req_size * 2));
+       node->objs = rte_realloc_socket(node->objs, size * sizeof(void *),
+                                       RTE_CACHE_LINE_SIZE, graph->socket);
+       RTE_VERIFY(node->objs);
+       node->size = size;
+       node->realloc_count++;
+}
+
 static int
 graph_to_dot(FILE *f, struct graph *graph)
 {
@@ -525,6 +540,37 @@ end:
        return -rc;
 }
 
+static void
+graph_scan_dump(FILE *f, rte_graph_t id, bool all)
+{
+       struct graph *graph;
+
+       RTE_VERIFY(f);
+       GRAPH_ID_CHECK(id);
+
+       STAILQ_FOREACH(graph, &graph_list, next) {
+               if (all == true) {
+                       graph_dump(f, graph);
+               } else if (graph->id == id) {
+                       graph_dump(f, graph);
+                       return;
+               }
+       }
+fail:
+       return;
+}
+
+void
+rte_graph_dump(FILE *f, rte_graph_t id)
+{
+       graph_scan_dump(f, id, false);
+}
+
+void
+rte_graph_list_dump(FILE *f)
+{
+       graph_scan_dump(f, 0, true);
+}
 
 rte_graph_t
 rte_graph_max_count(void)
@@ -532,9 +578,4 @@ 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);
-}
+RTE_LOG_REGISTER(rte_graph_logtype, lib.graph, INFO);