1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2010-2017 Intel Corporation
4 * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
6 * Derived from FreeBSD's bufring.h
7 * Used as BSD-3 Licensed with permission from Kip Macy.
17 * The Ring Manager is a fixed-size queue, implemented as a table of
18 * pointers. Head and tail pointers are modified atomically, allowing
19 * concurrent access to it. It has the following features:
21 * - FIFO (First In First Out)
22 * - Maximum size is fixed; the pointers are stored in a table.
23 * - Lockless implementation.
24 * - Multi- or single-consumer dequeue.
25 * - Multi- or single-producer enqueue.
29 * Note: the ring implementation is not preemptible. Refer to Programmer's
30 * guide/Environment Abstraction Layer/Multiple pthread/Known Issues/rte_ring
31 * for more information.
39 #include <rte_ring_core.h>
42 * Calculate the memory size needed for a ring
44 * This function returns the number of bytes needed for a ring, given
45 * the number of elements in it. This value is the sum of the size of
46 * the structure rte_ring and the size of the memory needed by the
47 * objects pointers. The value is aligned to a cache line size.
50 * The number of elements in the ring (must be a power of 2).
52 * - The memory size needed for the ring on success.
53 * - -EINVAL if count is not a power of 2.
55 ssize_t rte_ring_get_memsize(unsigned count);
58 * Initialize a ring structure.
60 * Initialize a ring structure in memory pointed by "r". The size of the
61 * memory area must be large enough to store the ring structure and the
62 * object table. It is advised to use rte_ring_get_memsize() to get the
65 * The ring size is set to *count*, which must be a power of two. Water
66 * marking is disabled by default. The real usable ring size is
67 * *count-1* instead of *count* to differentiate a free ring from an
70 * The ring is not added in RTE_TAILQ_RING global list. Indeed, the
71 * memory given by the caller may not be shareable among dpdk
75 * The pointer to the ring structure followed by the objects table.
77 * The name of the ring.
79 * The number of elements in the ring (must be a power of 2).
81 * An OR of the following:
82 * - RING_F_SP_ENQ: If this flag is set, the default behavior when
83 * using ``rte_ring_enqueue()`` or ``rte_ring_enqueue_bulk()``
84 * is "single-producer". Otherwise, it is "multi-producers".
85 * - RING_F_SC_DEQ: If this flag is set, the default behavior when
86 * using ``rte_ring_dequeue()`` or ``rte_ring_dequeue_bulk()``
87 * is "single-consumer". Otherwise, it is "multi-consumers".
89 * 0 on success, or a negative value on error.
91 int rte_ring_init(struct rte_ring *r, const char *name, unsigned count,
95 * Create a new ring named *name* in memory.
97 * This function uses ``memzone_reserve()`` to allocate memory. Then it
98 * calls rte_ring_init() to initialize an empty ring.
100 * The new ring size is set to *count*, which must be a power of
101 * two. Water marking is disabled by default. The real usable ring size
102 * is *count-1* instead of *count* to differentiate a free ring from an
105 * The ring is added in RTE_TAILQ_RING list.
108 * The name of the ring.
110 * The size of the ring (must be a power of 2).
112 * The *socket_id* argument is the socket identifier in case of
113 * NUMA. The value can be *SOCKET_ID_ANY* if there is no NUMA
114 * constraint for the reserved zone.
116 * An OR of the following:
117 * - RING_F_SP_ENQ: If this flag is set, the default behavior when
118 * using ``rte_ring_enqueue()`` or ``rte_ring_enqueue_bulk()``
119 * is "single-producer". Otherwise, it is "multi-producers".
120 * - RING_F_SC_DEQ: If this flag is set, the default behavior when
121 * using ``rte_ring_dequeue()`` or ``rte_ring_dequeue_bulk()``
122 * is "single-consumer". Otherwise, it is "multi-consumers".
124 * On success, the pointer to the new allocated ring. NULL on error with
125 * rte_errno set appropriately. Possible errno values include:
126 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
127 * - E_RTE_SECONDARY - function was called from a secondary process instance
128 * - EINVAL - count provided is not a power of 2
129 * - ENOSPC - the maximum number of memzones has already been allocated
130 * - EEXIST - a memzone with the same name already exists
131 * - ENOMEM - no appropriate memory area found in which to create memzone
133 struct rte_ring *rte_ring_create(const char *name, unsigned count,
134 int socket_id, unsigned flags);
137 * De-allocate all memory used by the ring.
142 void rte_ring_free(struct rte_ring *r);
145 * Dump the status of the ring to a file.
148 * A pointer to a file for output
150 * A pointer to the ring structure.
152 void rte_ring_dump(FILE *f, const struct rte_ring *r);
154 /* the actual enqueue of pointers on the ring.
155 * Placed here since identical code needed in both
156 * single and multi producer enqueue functions */
157 #define ENQUEUE_PTRS(r, ring_start, prod_head, obj_table, n, obj_type) do { \
159 const uint32_t size = (r)->size; \
160 uint32_t idx = prod_head & (r)->mask; \
161 obj_type *ring = (obj_type *)ring_start; \
162 if (likely(idx + n < size)) { \
163 for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
164 ring[idx] = obj_table[i]; \
165 ring[idx+1] = obj_table[i+1]; \
166 ring[idx+2] = obj_table[i+2]; \
167 ring[idx+3] = obj_table[i+3]; \
171 ring[idx++] = obj_table[i++]; /* fallthrough */ \
173 ring[idx++] = obj_table[i++]; /* fallthrough */ \
175 ring[idx++] = obj_table[i++]; \
178 for (i = 0; idx < size; i++, idx++)\
179 ring[idx] = obj_table[i]; \
180 for (idx = 0; i < n; i++, idx++) \
181 ring[idx] = obj_table[i]; \
185 /* the actual copy of pointers on the ring to obj_table.
186 * Placed here since identical code needed in both
187 * single and multi consumer dequeue functions */
188 #define DEQUEUE_PTRS(r, ring_start, cons_head, obj_table, n, obj_type) do { \
190 uint32_t idx = cons_head & (r)->mask; \
191 const uint32_t size = (r)->size; \
192 obj_type *ring = (obj_type *)ring_start; \
193 if (likely(idx + n < size)) { \
194 for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\
195 obj_table[i] = ring[idx]; \
196 obj_table[i+1] = ring[idx+1]; \
197 obj_table[i+2] = ring[idx+2]; \
198 obj_table[i+3] = ring[idx+3]; \
202 obj_table[i++] = ring[idx++]; /* fallthrough */ \
204 obj_table[i++] = ring[idx++]; /* fallthrough */ \
206 obj_table[i++] = ring[idx++]; \
209 for (i = 0; idx < size; i++, idx++) \
210 obj_table[i] = ring[idx]; \
211 for (idx = 0; i < n; i++, idx++) \
212 obj_table[i] = ring[idx]; \
216 /* Between load and load. there might be cpu reorder in weak model
218 * There are 2 choices for the users
219 * 1.use rmb() memory barrier
220 * 2.use one-direction load_acquire/store_release barrier,defined by
221 * CONFIG_RTE_USE_C11_MEM_MODEL=y
222 * It depends on performance test results.
223 * By default, move common functions to rte_ring_generic.h
225 #ifdef RTE_USE_C11_MEM_MODEL
226 #include "rte_ring_c11_mem.h"
228 #include "rte_ring_generic.h"
232 * @internal Enqueue several objects on the ring
235 * A pointer to the ring structure.
237 * A pointer to a table of void * pointers (objects).
239 * The number of objects to add in the ring from the obj_table.
241 * RTE_RING_QUEUE_FIXED: Enqueue a fixed number of items from a ring
242 * RTE_RING_QUEUE_VARIABLE: Enqueue as many items as possible from ring
244 * Indicates whether to use single producer or multi-producer head update
246 * returns the amount of space after the enqueue operation has finished
248 * Actual number of objects enqueued.
249 * If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.
251 static __rte_always_inline unsigned int
252 __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,
253 unsigned int n, enum rte_ring_queue_behavior behavior,
254 unsigned int is_sp, unsigned int *free_space)
256 uint32_t prod_head, prod_next;
257 uint32_t free_entries;
259 n = __rte_ring_move_prod_head(r, is_sp, n, behavior,
260 &prod_head, &prod_next, &free_entries);
264 ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);
266 update_tail(&r->prod, prod_head, prod_next, is_sp, 1);
268 if (free_space != NULL)
269 *free_space = free_entries - n;
274 * @internal Dequeue several objects from the ring
277 * A pointer to the ring structure.
279 * A pointer to a table of void * pointers (objects).
281 * The number of objects to pull from the ring.
283 * RTE_RING_QUEUE_FIXED: Dequeue a fixed number of items from a ring
284 * RTE_RING_QUEUE_VARIABLE: Dequeue as many items as possible from ring
286 * Indicates whether to use single consumer or multi-consumer head update
288 * returns the number of remaining ring entries after the dequeue has finished
290 * - Actual number of objects dequeued.
291 * If behavior == RTE_RING_QUEUE_FIXED, this will be 0 or n only.
293 static __rte_always_inline unsigned int
294 __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,
295 unsigned int n, enum rte_ring_queue_behavior behavior,
296 unsigned int is_sc, unsigned int *available)
298 uint32_t cons_head, cons_next;
301 n = __rte_ring_move_cons_head(r, (int)is_sc, n, behavior,
302 &cons_head, &cons_next, &entries);
306 DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);
308 update_tail(&r->cons, cons_head, cons_next, is_sc, 0);
311 if (available != NULL)
312 *available = entries - n;
317 * Enqueue several objects on the ring (multi-producers safe).
319 * This function uses a "compare and set" instruction to move the
320 * producer index atomically.
323 * A pointer to the ring structure.
325 * A pointer to a table of void * pointers (objects).
327 * The number of objects to add in the ring from the obj_table.
329 * if non-NULL, returns the amount of space in the ring after the
330 * enqueue operation has finished.
332 * The number of objects enqueued, either 0 or n
334 static __rte_always_inline unsigned int
335 rte_ring_mp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
336 unsigned int n, unsigned int *free_space)
338 return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
339 RTE_RING_SYNC_MT, free_space);
343 * Enqueue several objects on a ring (NOT multi-producers safe).
346 * A pointer to the ring structure.
348 * A pointer to a table of void * pointers (objects).
350 * The number of objects to add in the ring from the obj_table.
352 * if non-NULL, returns the amount of space in the ring after the
353 * enqueue operation has finished.
355 * The number of objects enqueued, either 0 or n
357 static __rte_always_inline unsigned int
358 rte_ring_sp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
359 unsigned int n, unsigned int *free_space)
361 return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
362 RTE_RING_SYNC_ST, free_space);
365 #ifdef ALLOW_EXPERIMENTAL_API
366 #include <rte_ring_elem.h>
370 * Enqueue several objects on a ring.
372 * This function calls the multi-producer or the single-producer
373 * version depending on the default behavior that was specified at
374 * ring creation time (see flags).
377 * A pointer to the ring structure.
379 * A pointer to a table of void * pointers (objects).
381 * The number of objects to add in the ring from the obj_table.
383 * if non-NULL, returns the amount of space in the ring after the
384 * enqueue operation has finished.
386 * The number of objects enqueued, either 0 or n
388 static __rte_always_inline unsigned int
389 rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
390 unsigned int n, unsigned int *free_space)
392 return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
393 r->prod.sync_type, free_space);
397 * Enqueue one object on a ring (multi-producers safe).
399 * This function uses a "compare and set" instruction to move the
400 * producer index atomically.
403 * A pointer to the ring structure.
405 * A pointer to the object to be added.
407 * - 0: Success; objects enqueued.
408 * - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
410 static __rte_always_inline int
411 rte_ring_mp_enqueue(struct rte_ring *r, void *obj)
413 return rte_ring_mp_enqueue_bulk(r, &obj, 1, NULL) ? 0 : -ENOBUFS;
417 * Enqueue one object on a ring (NOT multi-producers safe).
420 * A pointer to the ring structure.
422 * A pointer to the object to be added.
424 * - 0: Success; objects enqueued.
425 * - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
427 static __rte_always_inline int
428 rte_ring_sp_enqueue(struct rte_ring *r, void *obj)
430 return rte_ring_sp_enqueue_bulk(r, &obj, 1, NULL) ? 0 : -ENOBUFS;
434 * Enqueue one object on a ring.
436 * This function calls the multi-producer or the single-producer
437 * version, depending on the default behaviour that was specified at
438 * ring creation time (see flags).
441 * A pointer to the ring structure.
443 * A pointer to the object to be added.
445 * - 0: Success; objects enqueued.
446 * - -ENOBUFS: Not enough room in the ring to enqueue; no object is enqueued.
448 static __rte_always_inline int
449 rte_ring_enqueue(struct rte_ring *r, void *obj)
451 return rte_ring_enqueue_bulk(r, &obj, 1, NULL) ? 0 : -ENOBUFS;
455 * Dequeue several objects from a ring (multi-consumers safe).
457 * This function uses a "compare and set" instruction to move the
458 * consumer index atomically.
461 * A pointer to the ring structure.
463 * A pointer to a table of void * pointers (objects) that will be filled.
465 * The number of objects to dequeue from the ring to the obj_table.
467 * If non-NULL, returns the number of remaining ring entries after the
468 * dequeue has finished.
470 * The number of objects dequeued, either 0 or n
472 static __rte_always_inline unsigned int
473 rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table,
474 unsigned int n, unsigned int *available)
476 return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
477 RTE_RING_SYNC_MT, available);
481 * Dequeue several objects from a ring (NOT multi-consumers safe).
484 * A pointer to the ring structure.
486 * A pointer to a table of void * pointers (objects) that will be filled.
488 * The number of objects to dequeue from the ring to the obj_table,
489 * must be strictly positive.
491 * If non-NULL, returns the number of remaining ring entries after the
492 * dequeue has finished.
494 * The number of objects dequeued, either 0 or n
496 static __rte_always_inline unsigned int
497 rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table,
498 unsigned int n, unsigned int *available)
500 return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
501 RTE_RING_SYNC_ST, available);
505 * Dequeue several objects from a ring.
507 * This function calls the multi-consumers or the single-consumer
508 * version, depending on the default behaviour that was specified at
509 * ring creation time (see flags).
512 * A pointer to the ring structure.
514 * A pointer to a table of void * pointers (objects) that will be filled.
516 * The number of objects to dequeue from the ring to the obj_table.
518 * If non-NULL, returns the number of remaining ring entries after the
519 * dequeue has finished.
521 * The number of objects dequeued, either 0 or n
523 static __rte_always_inline unsigned int
524 rte_ring_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n,
525 unsigned int *available)
527 return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
528 r->cons.sync_type, available);
532 * Dequeue one object from a ring (multi-consumers safe).
534 * This function uses a "compare and set" instruction to move the
535 * consumer index atomically.
538 * A pointer to the ring structure.
540 * A pointer to a void * pointer (object) that will be filled.
542 * - 0: Success; objects dequeued.
543 * - -ENOENT: Not enough entries in the ring to dequeue; no object is
546 static __rte_always_inline int
547 rte_ring_mc_dequeue(struct rte_ring *r, void **obj_p)
549 return rte_ring_mc_dequeue_bulk(r, obj_p, 1, NULL) ? 0 : -ENOENT;
553 * Dequeue one object from a ring (NOT multi-consumers safe).
556 * A pointer to the ring structure.
558 * A pointer to a void * pointer (object) that will be filled.
560 * - 0: Success; objects dequeued.
561 * - -ENOENT: Not enough entries in the ring to dequeue, no object is
564 static __rte_always_inline int
565 rte_ring_sc_dequeue(struct rte_ring *r, void **obj_p)
567 return rte_ring_sc_dequeue_bulk(r, obj_p, 1, NULL) ? 0 : -ENOENT;
571 * Dequeue one object from a ring.
573 * This function calls the multi-consumers or the single-consumer
574 * version depending on the default behaviour that was specified at
575 * ring creation time (see flags).
578 * A pointer to the ring structure.
580 * A pointer to a void * pointer (object) that will be filled.
582 * - 0: Success, objects dequeued.
583 * - -ENOENT: Not enough entries in the ring to dequeue, no object is
586 static __rte_always_inline int
587 rte_ring_dequeue(struct rte_ring *r, void **obj_p)
589 return rte_ring_dequeue_bulk(r, obj_p, 1, NULL) ? 0 : -ENOENT;
595 * This function flush all the elements in a ring
597 * @b EXPERIMENTAL: this API may change without prior notice
600 * Make sure the ring is not in use while calling this function.
603 * A pointer to the ring structure.
607 rte_ring_reset(struct rte_ring *r);
610 * Return the number of entries in a ring.
613 * A pointer to the ring structure.
615 * The number of entries in the ring.
617 static inline unsigned
618 rte_ring_count(const struct rte_ring *r)
620 uint32_t prod_tail = r->prod.tail;
621 uint32_t cons_tail = r->cons.tail;
622 uint32_t count = (prod_tail - cons_tail) & r->mask;
623 return (count > r->capacity) ? r->capacity : count;
627 * Return the number of free entries in a ring.
630 * A pointer to the ring structure.
632 * The number of free entries in the ring.
634 static inline unsigned
635 rte_ring_free_count(const struct rte_ring *r)
637 return r->capacity - rte_ring_count(r);
641 * Test if a ring is full.
644 * A pointer to the ring structure.
646 * - 1: The ring is full.
647 * - 0: The ring is not full.
650 rte_ring_full(const struct rte_ring *r)
652 return rte_ring_free_count(r) == 0;
656 * Test if a ring is empty.
659 * A pointer to the ring structure.
661 * - 1: The ring is empty.
662 * - 0: The ring is not empty.
665 rte_ring_empty(const struct rte_ring *r)
667 return rte_ring_count(r) == 0;
671 * Return the size of the ring.
674 * A pointer to the ring structure.
676 * The size of the data store used by the ring.
677 * NOTE: this is not the same as the usable space in the ring. To query that
678 * use ``rte_ring_get_capacity()``.
680 static inline unsigned int
681 rte_ring_get_size(const struct rte_ring *r)
687 * Return the number of elements which can be stored in the ring.
690 * A pointer to the ring structure.
692 * The usable size of the ring.
694 static inline unsigned int
695 rte_ring_get_capacity(const struct rte_ring *r)
701 * Return sync type used by producer in the ring.
704 * A pointer to the ring structure.
706 * Producer sync type value.
708 static inline enum rte_ring_sync_type
709 rte_ring_get_prod_sync_type(const struct rte_ring *r)
711 return r->prod.sync_type;
715 * Check is the ring for single producer.
718 * A pointer to the ring structure.
720 * true if ring is SP, zero otherwise.
723 rte_ring_is_prod_single(const struct rte_ring *r)
725 return (rte_ring_get_prod_sync_type(r) == RTE_RING_SYNC_ST);
729 * Return sync type used by consumer in the ring.
732 * A pointer to the ring structure.
734 * Consumer sync type value.
736 static inline enum rte_ring_sync_type
737 rte_ring_get_cons_sync_type(const struct rte_ring *r)
739 return r->cons.sync_type;
743 * Check is the ring for single consumer.
746 * A pointer to the ring structure.
748 * true if ring is SC, zero otherwise.
751 rte_ring_is_cons_single(const struct rte_ring *r)
753 return (rte_ring_get_cons_sync_type(r) == RTE_RING_SYNC_ST);
757 * Dump the status of all rings on the console
760 * A pointer to a file for output
762 void rte_ring_list_dump(FILE *f);
765 * Search a ring from its name
768 * The name of the ring.
770 * The pointer to the ring matching the name, or NULL if not found,
771 * with rte_errno set appropriately. Possible rte_errno values include:
772 * - ENOENT - required entry not available to return.
774 struct rte_ring *rte_ring_lookup(const char *name);
777 * Enqueue several objects on the ring (multi-producers safe).
779 * This function uses a "compare and set" instruction to move the
780 * producer index atomically.
783 * A pointer to the ring structure.
785 * A pointer to a table of void * pointers (objects).
787 * The number of objects to add in the ring from the obj_table.
789 * if non-NULL, returns the amount of space in the ring after the
790 * enqueue operation has finished.
792 * - n: Actual number of objects enqueued.
794 static __rte_always_inline unsigned
795 rte_ring_mp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
796 unsigned int n, unsigned int *free_space)
798 return __rte_ring_do_enqueue(r, obj_table, n,
799 RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, free_space);
803 * Enqueue several objects on a ring (NOT multi-producers safe).
806 * A pointer to the ring structure.
808 * A pointer to a table of void * pointers (objects).
810 * The number of objects to add in the ring from the obj_table.
812 * if non-NULL, returns the amount of space in the ring after the
813 * enqueue operation has finished.
815 * - n: Actual number of objects enqueued.
817 static __rte_always_inline unsigned
818 rte_ring_sp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
819 unsigned int n, unsigned int *free_space)
821 return __rte_ring_do_enqueue(r, obj_table, n,
822 RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, free_space);
826 * Enqueue several objects on a ring.
828 * This function calls the multi-producer or the single-producer
829 * version depending on the default behavior that was specified at
830 * ring creation time (see flags).
833 * A pointer to the ring structure.
835 * A pointer to a table of void * pointers (objects).
837 * The number of objects to add in the ring from the obj_table.
839 * if non-NULL, returns the amount of space in the ring after the
840 * enqueue operation has finished.
842 * - n: Actual number of objects enqueued.
844 static __rte_always_inline unsigned
845 rte_ring_enqueue_burst(struct rte_ring *r, void * const *obj_table,
846 unsigned int n, unsigned int *free_space)
848 return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_VARIABLE,
849 r->prod.sync_type, free_space);
853 * Dequeue several objects from a ring (multi-consumers safe). When the request
854 * objects are more than the available objects, only dequeue the actual number
857 * This function uses a "compare and set" instruction to move the
858 * consumer index atomically.
861 * A pointer to the ring structure.
863 * A pointer to a table of void * pointers (objects) that will be filled.
865 * The number of objects to dequeue from the ring to the obj_table.
867 * If non-NULL, returns the number of remaining ring entries after the
868 * dequeue has finished.
870 * - n: Actual number of objects dequeued, 0 if ring is empty
872 static __rte_always_inline unsigned
873 rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table,
874 unsigned int n, unsigned int *available)
876 return __rte_ring_do_dequeue(r, obj_table, n,
877 RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_MT, available);
881 * Dequeue several objects from a ring (NOT multi-consumers safe).When the
882 * request objects are more than the available objects, only dequeue the
883 * actual number of objects
886 * A pointer to the ring structure.
888 * A pointer to a table of void * pointers (objects) that will be filled.
890 * The number of objects to dequeue from the ring to the obj_table.
892 * If non-NULL, returns the number of remaining ring entries after the
893 * dequeue has finished.
895 * - n: Actual number of objects dequeued, 0 if ring is empty
897 static __rte_always_inline unsigned
898 rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table,
899 unsigned int n, unsigned int *available)
901 return __rte_ring_do_dequeue(r, obj_table, n,
902 RTE_RING_QUEUE_VARIABLE, RTE_RING_SYNC_ST, available);
906 * Dequeue multiple objects from a ring up to a maximum number.
908 * This function calls the multi-consumers or the single-consumer
909 * version, depending on the default behaviour that was specified at
910 * ring creation time (see flags).
913 * A pointer to the ring structure.
915 * A pointer to a table of void * pointers (objects) that will be filled.
917 * The number of objects to dequeue from the ring to the obj_table.
919 * If non-NULL, returns the number of remaining ring entries after the
920 * dequeue has finished.
922 * - Number of objects dequeued
924 static __rte_always_inline unsigned
925 rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table,
926 unsigned int n, unsigned int *available)
928 return __rte_ring_do_dequeue(r, obj_table, n,
929 RTE_RING_QUEUE_VARIABLE,
930 r->cons.sync_type, available);
937 #endif /* _RTE_RING_H_ */