xref: /dpdk/lib/stack/rte_stack_lf.c (revision 99a2dd955fba6e4cc23b77d590a033650ced9c45)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation
3  */
4 
5 #include "rte_stack.h"
6 
7 void
rte_stack_lf_init(struct rte_stack * s,unsigned int count)8 rte_stack_lf_init(struct rte_stack *s, unsigned int count)
9 {
10 	struct rte_stack_lf_elem *elems = s->stack_lf.elems;
11 	unsigned int i;
12 
13 	for (i = 0; i < count; i++)
14 		__rte_stack_lf_push_elems(&s->stack_lf.free,
15 					  &elems[i], &elems[i], 1);
16 }
17 
18 ssize_t
rte_stack_lf_get_memsize(unsigned int count)19 rte_stack_lf_get_memsize(unsigned int count)
20 {
21 	ssize_t sz = sizeof(struct rte_stack);
22 
23 	sz += RTE_CACHE_LINE_ROUNDUP(count * sizeof(struct rte_stack_lf_elem));
24 
25 	/* Add padding to avoid false sharing conflicts caused by
26 	 * next-line hardware prefetchers.
27 	 */
28 	sz += 2 * RTE_CACHE_LINE_SIZE;
29 
30 	return sz;
31 }
32