graph: populate fastpath memory for graph reel
[dpdk.git] / lib / librte_graph / graph.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2020 Marvell International Ltd.
3  */
4
5 #include <rte_malloc.h>
6 #include <rte_spinlock.h>
7
8 #include "graph_private.h"
9
10 static rte_spinlock_t graph_lock = RTE_SPINLOCK_INITIALIZER;
11 int rte_graph_logtype;
12
13 void
14 graph_spinlock_lock(void)
15 {
16         rte_spinlock_lock(&graph_lock);
17 }
18
19 void
20 graph_spinlock_unlock(void)
21 {
22         rte_spinlock_unlock(&graph_lock);
23 }
24
25 void __rte_noinline
26 __rte_node_stream_alloc(struct rte_graph *graph, struct rte_node *node)
27 {
28         uint16_t size = node->size;
29
30         RTE_VERIFY(size != UINT16_MAX);
31         /* Allocate double amount of size to avoid immediate realloc */
32         size = RTE_MIN(UINT16_MAX, RTE_MAX(RTE_GRAPH_BURST_SIZE, size * 2));
33         node->objs = rte_realloc_socket(node->objs, size * sizeof(void *),
34                                         RTE_CACHE_LINE_SIZE, graph->socket);
35         RTE_VERIFY(node->objs);
36         node->size = size;
37         node->realloc_count++;
38 }