DPDK  2.2.0
rte_ring.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  * * Neither the name of Intel Corporation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Derived from FreeBSD's bufring.h
36  *
37  **************************************************************************
38  *
39  * Copyright (c) 2007-2009 Kip Macy kmacy@freebsd.org
40  * All rights reserved.
41  *
42  * Redistribution and use in source and binary forms, with or without
43  * modification, are permitted provided that the following conditions are met:
44  *
45  * 1. Redistributions of source code must retain the above copyright notice,
46  * this list of conditions and the following disclaimer.
47  *
48  * 2. The name of Kip Macy nor the names of other
49  * contributors may be used to endorse or promote products derived from
50  * this software without specific prior written permission.
51  *
52  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
53  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
56  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
57  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
58  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
59  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
60  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
61  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
62  * POSSIBILITY OF SUCH DAMAGE.
63  *
64  ***************************************************************************/
65 
66 #ifndef _RTE_RING_H_
67 #define _RTE_RING_H_
68 
90 #ifdef __cplusplus
91 extern "C" {
92 #endif
93 
94 #include <stdio.h>
95 #include <stdint.h>
96 #include <sys/queue.h>
97 #include <errno.h>
98 #include <rte_common.h>
99 #include <rte_memory.h>
100 #include <rte_lcore.h>
101 #include <rte_atomic.h>
102 #include <rte_branch_prediction.h>
103 
104 #define RTE_TAILQ_RING_NAME "RTE_RING"
105 
106 enum rte_ring_queue_behavior {
107  RTE_RING_QUEUE_FIXED = 0, /* Enq/Deq a fixed number of items from a ring */
108  RTE_RING_QUEUE_VARIABLE /* Enq/Deq as many items a possible from ring */
109 };
110 
111 #ifdef RTE_LIBRTE_RING_DEBUG
112 
115 struct rte_ring_debug_stats {
116  uint64_t enq_success_bulk;
117  uint64_t enq_success_objs;
118  uint64_t enq_quota_bulk;
119  uint64_t enq_quota_objs;
120  uint64_t enq_fail_bulk;
121  uint64_t enq_fail_objs;
122  uint64_t deq_success_bulk;
123  uint64_t deq_success_objs;
124  uint64_t deq_fail_bulk;
125  uint64_t deq_fail_objs;
127 #endif
128 
129 #define RTE_RING_NAMESIZE 32
130 #define RTE_RING_MZ_PREFIX "RG_"
131 
132 #ifndef RTE_RING_PAUSE_REP_COUNT
133 #define RTE_RING_PAUSE_REP_COUNT 0
135 #endif
136 
137 struct rte_memzone; /* forward declaration, so as not to require memzone.h */
138 
149 struct rte_ring {
151  int flags;
152  const struct rte_memzone *memzone;
156  struct prod {
157  uint32_t watermark;
158  uint32_t sp_enqueue;
159  uint32_t size;
160  uint32_t mask;
161  volatile uint32_t head;
162  volatile uint32_t tail;
163  } prod __rte_cache_aligned;
164 
166  struct cons {
167  uint32_t sc_dequeue;
168  uint32_t size;
169  uint32_t mask;
170  volatile uint32_t head;
171  volatile uint32_t tail;
172 #ifdef RTE_RING_SPLIT_PROD_CONS
173  } cons __rte_cache_aligned;
174 #else
175  } cons;
176 #endif
177 
178 #ifdef RTE_LIBRTE_RING_DEBUG
179  struct rte_ring_debug_stats stats[RTE_MAX_LCORE];
180 #endif
181 
182  void * ring[0] __rte_cache_aligned;
185 };
186 
187 #define RING_F_SP_ENQ 0x0001
188 #define RING_F_SC_DEQ 0x0002
189 #define RTE_RING_QUOT_EXCEED (1 << 31)
190 #define RTE_RING_SZ_MASK (unsigned)(0x0fffffff)
201 #ifdef RTE_LIBRTE_RING_DEBUG
202 #define __RING_STAT_ADD(r, name, n) do { \
203  unsigned __lcore_id = rte_lcore_id(); \
204  if (__lcore_id < RTE_MAX_LCORE) { \
205  r->stats[__lcore_id].name##_objs += n; \
206  r->stats[__lcore_id].name##_bulk += 1; \
207  } \
208  } while(0)
209 #else
210 #define __RING_STAT_ADD(r, name, n) do {} while(0)
211 #endif
212 
227 ssize_t rte_ring_get_memsize(unsigned count);
228 
263 int rte_ring_init(struct rte_ring *r, const char *name, unsigned count,
264  unsigned flags);
265 
305 struct rte_ring *rte_ring_create(const char *name, unsigned count,
306  int socket_id, unsigned flags);
313 void rte_ring_free(struct rte_ring *r);
314 
333 int rte_ring_set_water_mark(struct rte_ring *r, unsigned count);
334 
343 void rte_ring_dump(FILE *f, const struct rte_ring *r);
344 
345 /* the actual enqueue of pointers on the ring.
346  * Placed here since identical code needed in both
347  * single and multi producer enqueue functions */
348 #define ENQUEUE_PTRS() do { \
349  const uint32_t size = r->prod.size; \
350  uint32_t idx = prod_head & mask; \
351  if (likely(idx + n < size)) { \
352  for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
353  r->ring[idx] = obj_table[i]; \
354  r->ring[idx+1] = obj_table[i+1]; \
355  r->ring[idx+2] = obj_table[i+2]; \
356  r->ring[idx+3] = obj_table[i+3]; \
357  } \
358  switch (n & 0x3) { \
359  case 3: r->ring[idx++] = obj_table[i++]; \
360  case 2: r->ring[idx++] = obj_table[i++]; \
361  case 1: r->ring[idx++] = obj_table[i++]; \
362  } \
363  } else { \
364  for (i = 0; idx < size; i++, idx++)\
365  r->ring[idx] = obj_table[i]; \
366  for (idx = 0; i < n; i++, idx++) \
367  r->ring[idx] = obj_table[i]; \
368  } \
369 } while(0)
370 
371 /* the actual copy of pointers on the ring to obj_table.
372  * Placed here since identical code needed in both
373  * single and multi consumer dequeue functions */
374 #define DEQUEUE_PTRS() do { \
375  uint32_t idx = cons_head & mask; \
376  const uint32_t size = r->cons.size; \
377  if (likely(idx + n < size)) { \
378  for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\
379  obj_table[i] = r->ring[idx]; \
380  obj_table[i+1] = r->ring[idx+1]; \
381  obj_table[i+2] = r->ring[idx+2]; \
382  obj_table[i+3] = r->ring[idx+3]; \
383  } \
384  switch (n & 0x3) { \
385  case 3: obj_table[i++] = r->ring[idx++]; \
386  case 2: obj_table[i++] = r->ring[idx++]; \
387  case 1: obj_table[i++] = r->ring[idx++]; \
388  } \
389  } else { \
390  for (i = 0; idx < size; i++, idx++) \
391  obj_table[i] = r->ring[idx]; \
392  for (idx = 0; i < n; i++, idx++) \
393  obj_table[i] = r->ring[idx]; \
394  } \
395 } while (0)
396 
422 static inline int __attribute__((always_inline))
423 __rte_ring_mp_do_enqueue(struct rte_ring *r, void * const *obj_table,
424  unsigned n, enum rte_ring_queue_behavior behavior)
425 {
426  uint32_t prod_head, prod_next;
427  uint32_t cons_tail, free_entries;
428  const unsigned max = n;
429  int success;
430  unsigned i, rep = 0;
431  uint32_t mask = r->prod.mask;
432  int ret;
433 
434  /* move prod.head atomically */
435  do {
436  /* Reset n to the initial burst count */
437  n = max;
438 
439  prod_head = r->prod.head;
440  cons_tail = r->cons.tail;
441  /* The subtraction is done between two unsigned 32bits value
442  * (the result is always modulo 32 bits even if we have
443  * prod_head > cons_tail). So 'free_entries' is always between 0
444  * and size(ring)-1. */
445  free_entries = (mask + cons_tail - prod_head);
446 
447  /* check that we have enough room in ring */
448  if (unlikely(n > free_entries)) {
449  if (behavior == RTE_RING_QUEUE_FIXED) {
450  __RING_STAT_ADD(r, enq_fail, n);
451  return -ENOBUFS;
452  }
453  else {
454  /* No free entry available */
455  if (unlikely(free_entries == 0)) {
456  __RING_STAT_ADD(r, enq_fail, n);
457  return 0;
458  }
459 
460  n = free_entries;
461  }
462  }
463 
464  prod_next = prod_head + n;
465  success = rte_atomic32_cmpset(&r->prod.head, prod_head,
466  prod_next);
467  } while (unlikely(success == 0));
468 
469  /* write entries in ring */
470  ENQUEUE_PTRS();
471  rte_smp_wmb();
472 
473  /* if we exceed the watermark */
474  if (unlikely(((mask + 1) - free_entries + n) > r->prod.watermark)) {
475  ret = (behavior == RTE_RING_QUEUE_FIXED) ? -EDQUOT :
476  (int)(n | RTE_RING_QUOT_EXCEED);
477  __RING_STAT_ADD(r, enq_quota, n);
478  }
479  else {
480  ret = (behavior == RTE_RING_QUEUE_FIXED) ? 0 : n;
481  __RING_STAT_ADD(r, enq_success, n);
482  }
483 
484  /*
485  * If there are other enqueues in progress that preceded us,
486  * we need to wait for them to complete
487  */
488  while (unlikely(r->prod.tail != prod_head)) {
489  rte_pause();
490 
491  /* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting
492  * for other thread finish. It gives pre-empted thread a chance
493  * to proceed and finish with ring dequeue operation. */
495  ++rep == RTE_RING_PAUSE_REP_COUNT) {
496  rep = 0;
497  sched_yield();
498  }
499  }
500  r->prod.tail = prod_next;
501  return ret;
502 }
503 
526 static inline int __attribute__((always_inline))
527 __rte_ring_sp_do_enqueue(struct rte_ring *r, void * const *obj_table,
528  unsigned n, enum rte_ring_queue_behavior behavior)
529 {
530  uint32_t prod_head, cons_tail;
531  uint32_t prod_next, free_entries;
532  unsigned i;
533  uint32_t mask = r->prod.mask;
534  int ret;
535 
536  prod_head = r->prod.head;
537  cons_tail = r->cons.tail;
538  /* The subtraction is done between two unsigned 32bits value
539  * (the result is always modulo 32 bits even if we have
540  * prod_head > cons_tail). So 'free_entries' is always between 0
541  * and size(ring)-1. */
542  free_entries = mask + cons_tail - prod_head;
543 
544  /* check that we have enough room in ring */
545  if (unlikely(n > free_entries)) {
546  if (behavior == RTE_RING_QUEUE_FIXED) {
547  __RING_STAT_ADD(r, enq_fail, n);
548  return -ENOBUFS;
549  }
550  else {
551  /* No free entry available */
552  if (unlikely(free_entries == 0)) {
553  __RING_STAT_ADD(r, enq_fail, n);
554  return 0;
555  }
556 
557  n = free_entries;
558  }
559  }
560 
561  prod_next = prod_head + n;
562  r->prod.head = prod_next;
563 
564  /* write entries in ring */
565  ENQUEUE_PTRS();
566  rte_smp_wmb();
567 
568  /* if we exceed the watermark */
569  if (unlikely(((mask + 1) - free_entries + n) > r->prod.watermark)) {
570  ret = (behavior == RTE_RING_QUEUE_FIXED) ? -EDQUOT :
571  (int)(n | RTE_RING_QUOT_EXCEED);
572  __RING_STAT_ADD(r, enq_quota, n);
573  }
574  else {
575  ret = (behavior == RTE_RING_QUEUE_FIXED) ? 0 : n;
576  __RING_STAT_ADD(r, enq_success, n);
577  }
578 
579  r->prod.tail = prod_next;
580  return ret;
581 }
582 
610 static inline int __attribute__((always_inline))
611 __rte_ring_mc_do_dequeue(struct rte_ring *r, void **obj_table,
612  unsigned n, enum rte_ring_queue_behavior behavior)
613 {
614  uint32_t cons_head, prod_tail;
615  uint32_t cons_next, entries;
616  const unsigned max = n;
617  int success;
618  unsigned i, rep = 0;
619  uint32_t mask = r->prod.mask;
620 
621  /* move cons.head atomically */
622  do {
623  /* Restore n as it may change every loop */
624  n = max;
625 
626  cons_head = r->cons.head;
627  prod_tail = r->prod.tail;
628  /* The subtraction is done between two unsigned 32bits value
629  * (the result is always modulo 32 bits even if we have
630  * cons_head > prod_tail). So 'entries' is always between 0
631  * and size(ring)-1. */
632  entries = (prod_tail - cons_head);
633 
634  /* Set the actual entries for dequeue */
635  if (n > entries) {
636  if (behavior == RTE_RING_QUEUE_FIXED) {
637  __RING_STAT_ADD(r, deq_fail, n);
638  return -ENOENT;
639  }
640  else {
641  if (unlikely(entries == 0)){
642  __RING_STAT_ADD(r, deq_fail, n);
643  return 0;
644  }
645 
646  n = entries;
647  }
648  }
649 
650  cons_next = cons_head + n;
651  success = rte_atomic32_cmpset(&r->cons.head, cons_head,
652  cons_next);
653  } while (unlikely(success == 0));
654 
655  /* copy in table */
656  DEQUEUE_PTRS();
657  rte_smp_rmb();
658 
659  /*
660  * If there are other dequeues in progress that preceded us,
661  * we need to wait for them to complete
662  */
663  while (unlikely(r->cons.tail != cons_head)) {
664  rte_pause();
665 
666  /* Set RTE_RING_PAUSE_REP_COUNT to avoid spin too long waiting
667  * for other thread finish. It gives pre-empted thread a chance
668  * to proceed and finish with ring dequeue operation. */
670  ++rep == RTE_RING_PAUSE_REP_COUNT) {
671  rep = 0;
672  sched_yield();
673  }
674  }
675  __RING_STAT_ADD(r, deq_success, n);
676  r->cons.tail = cons_next;
677 
678  return behavior == RTE_RING_QUEUE_FIXED ? 0 : n;
679 }
680 
704 static inline int __attribute__((always_inline))
705 __rte_ring_sc_do_dequeue(struct rte_ring *r, void **obj_table,
706  unsigned n, enum rte_ring_queue_behavior behavior)
707 {
708  uint32_t cons_head, prod_tail;
709  uint32_t cons_next, entries;
710  unsigned i;
711  uint32_t mask = r->prod.mask;
712 
713  cons_head = r->cons.head;
714  prod_tail = r->prod.tail;
715  /* The subtraction is done between two unsigned 32bits value
716  * (the result is always modulo 32 bits even if we have
717  * cons_head > prod_tail). So 'entries' is always between 0
718  * and size(ring)-1. */
719  entries = prod_tail - cons_head;
720 
721  if (n > entries) {
722  if (behavior == RTE_RING_QUEUE_FIXED) {
723  __RING_STAT_ADD(r, deq_fail, n);
724  return -ENOENT;
725  }
726  else {
727  if (unlikely(entries == 0)){
728  __RING_STAT_ADD(r, deq_fail, n);
729  return 0;
730  }
731 
732  n = entries;
733  }
734  }
735 
736  cons_next = cons_head + n;
737  r->cons.head = cons_next;
738 
739  /* copy in table */
740  DEQUEUE_PTRS();
741  rte_smp_rmb();
742 
743  __RING_STAT_ADD(r, deq_success, n);
744  r->cons.tail = cons_next;
745  return behavior == RTE_RING_QUEUE_FIXED ? 0 : n;
746 }
747 
766 static inline int __attribute__((always_inline))
767 rte_ring_mp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
768  unsigned n)
769 {
770  return __rte_ring_mp_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED);
771 }
772 
788 static inline int __attribute__((always_inline))
789 rte_ring_sp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
790  unsigned n)
791 {
792  return __rte_ring_sp_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED);
793 }
794 
814 static inline int __attribute__((always_inline))
815 rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
816  unsigned n)
817 {
818  if (r->prod.sp_enqueue)
819  return rte_ring_sp_enqueue_bulk(r, obj_table, n);
820  else
821  return rte_ring_mp_enqueue_bulk(r, obj_table, n);
822 }
823 
840 static inline int __attribute__((always_inline))
841 rte_ring_mp_enqueue(struct rte_ring *r, void *obj)
842 {
843  return rte_ring_mp_enqueue_bulk(r, &obj, 1);
844 }
845 
859 static inline int __attribute__((always_inline))
860 rte_ring_sp_enqueue(struct rte_ring *r, void *obj)
861 {
862  return rte_ring_sp_enqueue_bulk(r, &obj, 1);
863 }
864 
882 static inline int __attribute__((always_inline))
883 rte_ring_enqueue(struct rte_ring *r, void *obj)
884 {
885  if (r->prod.sp_enqueue)
886  return rte_ring_sp_enqueue(r, obj);
887  else
888  return rte_ring_mp_enqueue(r, obj);
889 }
890 
908 static inline int __attribute__((always_inline))
909 rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned n)
910 {
911  return __rte_ring_mc_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED);
912 }
913 
929 static inline int __attribute__((always_inline))
930 rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned n)
931 {
932  return __rte_ring_sc_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED);
933 }
934 
953 static inline int __attribute__((always_inline))
954 rte_ring_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned n)
955 {
956  if (r->cons.sc_dequeue)
957  return rte_ring_sc_dequeue_bulk(r, obj_table, n);
958  else
959  return rte_ring_mc_dequeue_bulk(r, obj_table, n);
960 }
961 
977 static inline int __attribute__((always_inline))
978 rte_ring_mc_dequeue(struct rte_ring *r, void **obj_p)
979 {
980  return rte_ring_mc_dequeue_bulk(r, obj_p, 1);
981 }
982 
995 static inline int __attribute__((always_inline))
996 rte_ring_sc_dequeue(struct rte_ring *r, void **obj_p)
997 {
998  return rte_ring_sc_dequeue_bulk(r, obj_p, 1);
999 }
1000 
1017 static inline int __attribute__((always_inline))
1018 rte_ring_dequeue(struct rte_ring *r, void **obj_p)
1019 {
1020  if (r->cons.sc_dequeue)
1021  return rte_ring_sc_dequeue(r, obj_p);
1022  else
1023  return rte_ring_mc_dequeue(r, obj_p);
1024 }
1025 
1035 static inline int
1036 rte_ring_full(const struct rte_ring *r)
1037 {
1038  uint32_t prod_tail = r->prod.tail;
1039  uint32_t cons_tail = r->cons.tail;
1040  return (((cons_tail - prod_tail - 1) & r->prod.mask) == 0);
1041 }
1042 
1052 static inline int
1053 rte_ring_empty(const struct rte_ring *r)
1054 {
1055  uint32_t prod_tail = r->prod.tail;
1056  uint32_t cons_tail = r->cons.tail;
1057  return !!(cons_tail == prod_tail);
1058 }
1059 
1068 static inline unsigned
1069 rte_ring_count(const struct rte_ring *r)
1070 {
1071  uint32_t prod_tail = r->prod.tail;
1072  uint32_t cons_tail = r->cons.tail;
1073  return ((prod_tail - cons_tail) & r->prod.mask);
1074 }
1075 
1084 static inline unsigned
1086 {
1087  uint32_t prod_tail = r->prod.tail;
1088  uint32_t cons_tail = r->cons.tail;
1089  return ((cons_tail - prod_tail - 1) & r->prod.mask);
1090 }
1091 
1098 void rte_ring_list_dump(FILE *f);
1099 
1110 struct rte_ring *rte_ring_lookup(const char *name);
1111 
1127 static inline unsigned __attribute__((always_inline))
1128 rte_ring_mp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
1129  unsigned n)
1130 {
1131  return __rte_ring_mp_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_VARIABLE);
1132 }
1133 
1146 static inline unsigned __attribute__((always_inline))
1147 rte_ring_sp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
1148  unsigned n)
1149 {
1150  return __rte_ring_sp_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_VARIABLE);
1151 }
1152 
1169 static inline unsigned __attribute__((always_inline))
1170 rte_ring_enqueue_burst(struct rte_ring *r, void * const *obj_table,
1171  unsigned n)
1172 {
1173  if (r->prod.sp_enqueue)
1174  return rte_ring_sp_enqueue_burst(r, obj_table, n);
1175  else
1176  return rte_ring_mp_enqueue_burst(r, obj_table, n);
1177 }
1178 
1196 static inline unsigned __attribute__((always_inline))
1197 rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
1198 {
1199  return __rte_ring_mc_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_VARIABLE);
1200 }
1201 
1216 static inline unsigned __attribute__((always_inline))
1217 rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
1218 {
1219  return __rte_ring_sc_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_VARIABLE);
1220 }
1221 
1238 static inline unsigned __attribute__((always_inline))
1239 rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned n)
1240 {
1241  if (r->cons.sc_dequeue)
1242  return rte_ring_sc_dequeue_burst(r, obj_table, n);
1243  else
1244  return rte_ring_mc_dequeue_burst(r, obj_table, n);
1245 }
1246 
1247 #ifdef __cplusplus
1248 }
1249 #endif
1250 
1251 #endif /* _RTE_RING_H_ */