DPDK  19.11.14
rte_stack_lf.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2019 Intel Corporation
3  */
4 
5 #ifndef _RTE_STACK_LF_H_
6 #define _RTE_STACK_LF_H_
7 
8 #if !(defined(RTE_ARCH_X86_64) || defined(RTE_ARCH_ARM64))
9 #include "rte_stack_lf_stubs.h"
10 #else
11 #ifdef RTE_USE_C11_MEM_MODEL
12 #include "rte_stack_lf_c11.h"
13 #else
14 #include "rte_stack_lf_generic.h"
15 #endif
16 
20 #define RTE_STACK_LF_SUPPORTED
21 #endif
22 
35 __rte_experimental
36 static __rte_always_inline unsigned int
37 __rte_stack_lf_push(struct rte_stack *s,
38  void * const *obj_table,
39  unsigned int n)
40 {
41  struct rte_stack_lf_elem *tmp, *first, *last = NULL;
42  unsigned int i;
43 
44  if (unlikely(n == 0))
45  return 0;
46 
47  /* Pop n free elements */
48  first = __rte_stack_lf_pop_elems(&s->stack_lf.free, n, NULL, &last);
49  if (unlikely(first == NULL))
50  return 0;
51 
52  /* Construct the list elements */
53  for (tmp = first, i = 0; i < n; i++, tmp = tmp->next)
54  tmp->data = obj_table[n - i - 1];
55 
56  /* Push them to the used list */
57  __rte_stack_lf_push_elems(&s->stack_lf.used, first, last, n);
58 
59  return n;
60 }
61 
74 __rte_experimental
75 static __rte_always_inline unsigned int
76 __rte_stack_lf_pop(struct rte_stack *s, void **obj_table, unsigned int n)
77 {
78  struct rte_stack_lf_elem *first, *last = NULL;
79 
80  if (unlikely(n == 0))
81  return 0;
82 
83  /* Pop n used elements */
84  first = __rte_stack_lf_pop_elems(&s->stack_lf.used,
85  n, obj_table, &last);
86  if (unlikely(first == NULL))
87  return 0;
88 
89  /* Push the list elements to the free list */
90  __rte_stack_lf_push_elems(&s->stack_lf.free, first, last, n);
91 
92  return n;
93 }
94 
103 void
104 rte_stack_lf_init(struct rte_stack *s, unsigned int count);
105 
114 ssize_t
115 rte_stack_lf_get_memsize(unsigned int count);
116 
117 #endif /* _RTE_STACK_LF_H_ */
#define __rte_always_inline
Definition: rte_common.h:158
#define unlikely(x)