05d3b5283c
The rte_stack library provides an API for configuration and use of a bounded stack of pointers. Push and pop operations are MT-safe, allowing concurrent access, and the interface supports pushing and popping multiple pointers at a time. The library's interface is modeled after another DPDK data structure, rte_ring, and its lock-based implementation is derived from the stack mempool handler. An upcoming commit will migrate the stack mempool handler to rte_stack. Signed-off-by: Gage Eads <gage.eads@intel.com> Reviewed-by: Olivier Matz <olivier.matz@6wind.com> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
27 lines
499 B
C
27 lines
499 B
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright(c) 2019 Intel Corporation
|
|
*/
|
|
|
|
#include "rte_stack.h"
|
|
|
|
void
|
|
rte_stack_std_init(struct rte_stack *s)
|
|
{
|
|
rte_spinlock_init(&s->stack_std.lock);
|
|
}
|
|
|
|
ssize_t
|
|
rte_stack_std_get_memsize(unsigned int count)
|
|
{
|
|
ssize_t sz = sizeof(struct rte_stack);
|
|
|
|
sz += RTE_CACHE_LINE_ROUNDUP(count * sizeof(void *));
|
|
|
|
/* Add padding to avoid false sharing conflicts caused by
|
|
* next-line hardware prefetchers.
|
|
*/
|
|
sz += 2 * RTE_CACHE_LINE_SIZE;
|
|
|
|
return sz;
|
|
}
|