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

Function rte_stack_create

dpdk/lib/stack/rte_stack.c:46–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46struct rte_stack *
47rte_stack_create(const char *name, unsigned int count, int socket_id,
48 uint32_t flags)
49{
50 char mz_name[RTE_MEMZONE_NAMESIZE];
51 struct rte_stack_list *stack_list;
52 const struct rte_memzone *mz;
53 struct rte_tailq_entry *te;
54 struct rte_stack *s;
55 unsigned int sz;
56 int ret;
57
58 if (flags & ~(RTE_STACK_F_LF)) {
59 STACK_LOG_ERR("Unsupported stack flags %#x", flags);
60 return NULL;
61 }
62
63#ifdef RTE_ARCH_64
64 RTE_BUILD_BUG_ON(sizeof(struct rte_stack_lf_head) != 16);
65#endif
66#if !defined(RTE_STACK_LF_SUPPORTED)
67 if (flags & RTE_STACK_F_LF) {
68 STACK_LOG_ERR("Lock-free stack is not supported on your platform");
69 rte_errno = ENOTSUP;
70 return NULL;
71 }
72#endif
73
74 sz = rte_stack_get_memsize(count, flags);
75
76 ret = snprintf(mz_name, sizeof(mz_name), "%s%s",
77 RTE_STACK_MZ_PREFIX, name);
78 if (ret < 0 || ret >= (int)sizeof(mz_name)) {
79 rte_errno = ENAMETOOLONG;
80 return NULL;
81 }
82
83 te = rte_zmalloc("STACK_TAILQ_ENTRY", sizeof(*te), 0);
84 if (te == NULL) {
85 STACK_LOG_ERR("Cannot reserve memory for tailq");
86 rte_errno = ENOMEM;
87 return NULL;
88 }
89
90 rte_mcfg_tailq_write_lock();
91
92 mz = rte_memzone_reserve_aligned(mz_name, sz, socket_id,
93 0, __alignof__(*s));
94 if (mz == NULL) {
95 STACK_LOG_ERR("Cannot reserve stack memzone!");
96 rte_mcfg_tailq_write_unlock();
97 rte_free(te);
98 return NULL;
99 }
100
101 s = mz->addr;
102
103 rte_stack_init(s, count, flags);

Callers 6

__stack_allocFunction · 0.85
__test_stack_perfFunction · 0.85
test_stack_basicFunction · 0.85
test_stack_name_reuseFunction · 0.85
test_stack_name_lengthFunction · 0.85
test_stack_multithreadedFunction · 0.85

Calls 10

rte_stack_get_memsizeFunction · 0.85
snprintfFunction · 0.85
rte_zmallocFunction · 0.85
rte_freeFunction · 0.85
rte_stack_initFunction · 0.85
rte_memzone_freeFunction · 0.85
strlcpyFunction · 0.50

Tested by 5

__test_stack_perfFunction · 0.68
test_stack_basicFunction · 0.68
test_stack_name_reuseFunction · 0.68
test_stack_name_lengthFunction · 0.68
test_stack_multithreadedFunction · 0.68