DPDK  20.11.10
rte_ring_hts.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2010-2020 Intel Corporation
4  * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
5  * All rights reserved.
6  * Derived from FreeBSD's bufring.h
7  * Used as BSD-3 Licensed with permission from Kip Macy.
8  */
9 
10 #ifndef _RTE_RING_HTS_H_
11 #define _RTE_RING_HTS_H_
12 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <rte_ring_hts_c11_mem.h>
33 
56 static __rte_always_inline unsigned int
57 __rte_ring_do_hts_enqueue_elem(struct rte_ring *r, const void *obj_table,
58  uint32_t esize, uint32_t n, enum rte_ring_queue_behavior behavior,
59  uint32_t *free_space)
60 {
61  uint32_t free, head;
62 
63  n = __rte_ring_hts_move_prod_head(r, n, behavior, &head, &free);
64 
65  if (n != 0) {
66  __rte_ring_enqueue_elems(r, head, obj_table, esize, n);
67  __rte_ring_hts_update_tail(&r->hts_prod, head, n, 1);
68  }
69 
70  if (free_space != NULL)
71  *free_space = free - n;
72  return n;
73 }
74 
97 static __rte_always_inline unsigned int
98 __rte_ring_do_hts_dequeue_elem(struct rte_ring *r, void *obj_table,
99  uint32_t esize, uint32_t n, enum rte_ring_queue_behavior behavior,
100  uint32_t *available)
101 {
102  uint32_t entries, head;
103 
104  n = __rte_ring_hts_move_cons_head(r, n, behavior, &head, &entries);
105 
106  if (n != 0) {
107  __rte_ring_dequeue_elems(r, head, obj_table, esize, n);
108  __rte_ring_hts_update_tail(&r->hts_cons, head, n, 0);
109  }
110 
111  if (available != NULL)
112  *available = entries - n;
113  return n;
114 }
115 
135 __rte_experimental
136 static __rte_always_inline unsigned int
137 rte_ring_mp_hts_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table,
138  unsigned int esize, unsigned int n, unsigned int *free_space)
139 {
140  return __rte_ring_do_hts_enqueue_elem(r, obj_table, esize, n,
141  RTE_RING_QUEUE_FIXED, free_space);
142 }
143 
163 __rte_experimental
164 static __rte_always_inline unsigned int
165 rte_ring_mc_hts_dequeue_bulk_elem(struct rte_ring *r, void *obj_table,
166  unsigned int esize, unsigned int n, unsigned int *available)
167 {
168  return __rte_ring_do_hts_dequeue_elem(r, obj_table, esize, n,
169  RTE_RING_QUEUE_FIXED, available);
170 }
171 
191 __rte_experimental
192 static __rte_always_inline unsigned int
193 rte_ring_mp_hts_enqueue_burst_elem(struct rte_ring *r, const void *obj_table,
194  unsigned int esize, unsigned int n, unsigned int *free_space)
195 {
196  return __rte_ring_do_hts_enqueue_elem(r, obj_table, esize, n,
197  RTE_RING_QUEUE_VARIABLE, free_space);
198 }
199 
221 __rte_experimental
222 static __rte_always_inline unsigned int
223 rte_ring_mc_hts_dequeue_burst_elem(struct rte_ring *r, void *obj_table,
224  unsigned int esize, unsigned int n, unsigned int *available)
225 {
226  return __rte_ring_do_hts_dequeue_elem(r, obj_table, esize, n,
227  RTE_RING_QUEUE_VARIABLE, available);
228 }
229 
245 __rte_experimental
246 static __rte_always_inline unsigned int
247 rte_ring_mp_hts_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
248  unsigned int n, unsigned int *free_space)
249 {
250  return rte_ring_mp_hts_enqueue_bulk_elem(r, obj_table,
251  sizeof(uintptr_t), n, free_space);
252 }
253 
269 __rte_experimental
270 static __rte_always_inline unsigned int
271 rte_ring_mc_hts_dequeue_bulk(struct rte_ring *r, void **obj_table,
272  unsigned int n, unsigned int *available)
273 {
274  return rte_ring_mc_hts_dequeue_bulk_elem(r, obj_table,
275  sizeof(uintptr_t), n, available);
276 }
277 
293 __rte_experimental
294 static __rte_always_inline unsigned int
295 rte_ring_mp_hts_enqueue_burst(struct rte_ring *r, void * const *obj_table,
296  unsigned int n, unsigned int *free_space)
297 {
298  return rte_ring_mp_hts_enqueue_burst_elem(r, obj_table,
299  sizeof(uintptr_t), n, free_space);
300 }
301 
319 __rte_experimental
320 static __rte_always_inline unsigned int
321 rte_ring_mc_hts_dequeue_burst(struct rte_ring *r, void **obj_table,
322  unsigned int n, unsigned int *available)
323 {
324  return rte_ring_mc_hts_dequeue_burst_elem(r, obj_table,
325  sizeof(uintptr_t), n, available);
326 }
327 
328 #ifdef __cplusplus
329 }
330 #endif
331 
332 #endif /* _RTE_RING_HTS_H_ */
static __rte_experimental __rte_always_inline unsigned int rte_ring_mp_hts_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring_hts.h:247
#define __rte_always_inline
Definition: rte_common.h:231
static __rte_experimental __rte_always_inline unsigned int rte_ring_mp_hts_enqueue_burst_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
Definition: rte_ring_hts.h:193
rte_ring_queue_behavior
Definition: rte_ring_core.h:44
static __rte_experimental __rte_always_inline unsigned int rte_ring_mp_hts_enqueue_bulk_elem(struct rte_ring *r, const void *obj_table, unsigned int esize, unsigned int n, unsigned int *free_space)
Definition: rte_ring_hts.h:137
static __rte_experimental __rte_always_inline unsigned int rte_ring_mp_hts_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring_hts.h:295
static __rte_experimental __rte_always_inline unsigned int rte_ring_mc_hts_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring_hts.h:271
static __rte_experimental __rte_always_inline unsigned int rte_ring_mc_hts_dequeue_bulk_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
Definition: rte_ring_hts.h:165
static __rte_experimental __rte_always_inline unsigned int rte_ring_mc_hts_dequeue_burst_elem(struct rte_ring *r, void *obj_table, unsigned int esize, unsigned int n, unsigned int *available)
Definition: rte_ring_hts.h:223
static __rte_experimental __rte_always_inline unsigned int rte_ring_mc_hts_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring_hts.h:321