DPDK  17.11.0
rte_ring.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2010-2017 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 #include <rte_memzone.h>
104 #include <rte_pause.h>
105 
106 #define RTE_TAILQ_RING_NAME "RTE_RING"
107 
108 enum rte_ring_queue_behavior {
109  RTE_RING_QUEUE_FIXED = 0, /* Enq/Deq a fixed number of items from a ring */
110  RTE_RING_QUEUE_VARIABLE /* Enq/Deq as many items as possible from ring */
111 };
112 
113 #define RTE_RING_MZ_PREFIX "RG_"
114 
115 #define RTE_RING_NAMESIZE (RTE_MEMZONE_NAMESIZE - \
116  sizeof(RTE_RING_MZ_PREFIX) + 1)
117 
118 struct rte_memzone; /* forward declaration, so as not to require memzone.h */
119 
120 #if RTE_CACHE_LINE_SIZE < 128
121 #define PROD_ALIGN (RTE_CACHE_LINE_SIZE * 2)
122 #define CONS_ALIGN (RTE_CACHE_LINE_SIZE * 2)
123 #else
124 #define PROD_ALIGN RTE_CACHE_LINE_SIZE
125 #define CONS_ALIGN RTE_CACHE_LINE_SIZE
126 #endif
127 
128 /* structure to hold a pair of head/tail values and other metadata */
129 struct rte_ring_headtail {
130  volatile uint32_t head;
131  volatile uint32_t tail;
132  uint32_t single;
133 };
134 
145 struct rte_ring {
146  /*
147  * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI
148  * compatibility requirements, it could be changed to RTE_RING_NAMESIZE
149  * next time the ABI changes
150  */
152  int flags;
153  const struct rte_memzone *memzone;
155  uint32_t size;
156  uint32_t mask;
157  uint32_t capacity;
160  struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN);
161 
163  struct rte_ring_headtail cons __rte_aligned(CONS_ALIGN);
164 };
165 
166 #define RING_F_SP_ENQ 0x0001
167 #define RING_F_SC_DEQ 0x0002
176 #define RING_F_EXACT_SZ 0x0004
177 #define RTE_RING_SZ_MASK (0x7fffffffU)
179 /* @internal defines for passing to the enqueue dequeue worker functions */
180 #define __IS_SP 1
181 #define __IS_MP 0
182 #define __IS_SC 1
183 #define __IS_MC 0
184 
199 ssize_t rte_ring_get_memsize(unsigned count);
200 
235 int rte_ring_init(struct rte_ring *r, const char *name, unsigned count,
236  unsigned flags);
237 
277 struct rte_ring *rte_ring_create(const char *name, unsigned count,
278  int socket_id, unsigned flags);
285 void rte_ring_free(struct rte_ring *r);
286 
295 void rte_ring_dump(FILE *f, const struct rte_ring *r);
296 
297 /* the actual enqueue of pointers on the ring.
298  * Placed here since identical code needed in both
299  * single and multi producer enqueue functions */
300 #define ENQUEUE_PTRS(r, ring_start, prod_head, obj_table, n, obj_type) do { \
301  unsigned int i; \
302  const uint32_t size = (r)->size; \
303  uint32_t idx = prod_head & (r)->mask; \
304  obj_type *ring = (obj_type *)ring_start; \
305  if (likely(idx + n < size)) { \
306  for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
307  ring[idx] = obj_table[i]; \
308  ring[idx+1] = obj_table[i+1]; \
309  ring[idx+2] = obj_table[i+2]; \
310  ring[idx+3] = obj_table[i+3]; \
311  } \
312  switch (n & 0x3) { \
313  case 3: \
314  ring[idx++] = obj_table[i++]; /* fallthrough */ \
315  case 2: \
316  ring[idx++] = obj_table[i++]; /* fallthrough */ \
317  case 1: \
318  ring[idx++] = obj_table[i++]; \
319  } \
320  } else { \
321  for (i = 0; idx < size; i++, idx++)\
322  ring[idx] = obj_table[i]; \
323  for (idx = 0; i < n; i++, idx++) \
324  ring[idx] = obj_table[i]; \
325  } \
326 } while (0)
327 
328 /* the actual copy of pointers on the ring to obj_table.
329  * Placed here since identical code needed in both
330  * single and multi consumer dequeue functions */
331 #define DEQUEUE_PTRS(r, ring_start, cons_head, obj_table, n, obj_type) do { \
332  unsigned int i; \
333  uint32_t idx = cons_head & (r)->mask; \
334  const uint32_t size = (r)->size; \
335  obj_type *ring = (obj_type *)ring_start; \
336  if (likely(idx + n < size)) { \
337  for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\
338  obj_table[i] = ring[idx]; \
339  obj_table[i+1] = ring[idx+1]; \
340  obj_table[i+2] = ring[idx+2]; \
341  obj_table[i+3] = ring[idx+3]; \
342  } \
343  switch (n & 0x3) { \
344  case 3: \
345  obj_table[i++] = ring[idx++]; /* fallthrough */ \
346  case 2: \
347  obj_table[i++] = ring[idx++]; /* fallthrough */ \
348  case 1: \
349  obj_table[i++] = ring[idx++]; \
350  } \
351  } else { \
352  for (i = 0; idx < size; i++, idx++) \
353  obj_table[i] = ring[idx]; \
354  for (idx = 0; i < n; i++, idx++) \
355  obj_table[i] = ring[idx]; \
356  } \
357 } while (0)
358 
359 static __rte_always_inline void
360 update_tail(struct rte_ring_headtail *ht, uint32_t old_val, uint32_t new_val,
361  uint32_t single)
362 {
363  /*
364  * If there are other enqueues/dequeues in progress that preceded us,
365  * we need to wait for them to complete
366  */
367  if (!single)
368  while (unlikely(ht->tail != old_val))
369  rte_pause();
370 
371  ht->tail = new_val;
372 }
373 
397 static __rte_always_inline unsigned int
398 __rte_ring_move_prod_head(struct rte_ring *r, int is_sp,
399  unsigned int n, enum rte_ring_queue_behavior behavior,
400  uint32_t *old_head, uint32_t *new_head,
401  uint32_t *free_entries)
402 {
403  const uint32_t capacity = r->capacity;
404  unsigned int max = n;
405  int success;
406 
407  do {
408  /* Reset n to the initial burst count */
409  n = max;
410 
411  *old_head = r->prod.head;
412 
413  /* add rmb barrier to avoid load/load reorder in weak
414  * memory model. It is noop on x86
415  */
416  rte_smp_rmb();
417 
418  const uint32_t cons_tail = r->cons.tail;
419  /*
420  * The subtraction is done between two unsigned 32bits value
421  * (the result is always modulo 32 bits even if we have
422  * *old_head > cons_tail). So 'free_entries' is always between 0
423  * and capacity (which is < size).
424  */
425  *free_entries = (capacity + cons_tail - *old_head);
426 
427  /* check that we have enough room in ring */
428  if (unlikely(n > *free_entries))
429  n = (behavior == RTE_RING_QUEUE_FIXED) ?
430  0 : *free_entries;
431 
432  if (n == 0)
433  return 0;
434 
435  *new_head = *old_head + n;
436  if (is_sp)
437  r->prod.head = *new_head, success = 1;
438  else
439  success = rte_atomic32_cmpset(&r->prod.head,
440  *old_head, *new_head);
441  } while (unlikely(success == 0));
442  return n;
443 }
444 
465 static __rte_always_inline unsigned int
466 __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table,
467  unsigned int n, enum rte_ring_queue_behavior behavior,
468  int is_sp, unsigned int *free_space)
469 {
470  uint32_t prod_head, prod_next;
471  uint32_t free_entries;
472 
473  n = __rte_ring_move_prod_head(r, is_sp, n, behavior,
474  &prod_head, &prod_next, &free_entries);
475  if (n == 0)
476  goto end;
477 
478  ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n, void *);
479  rte_smp_wmb();
480 
481  update_tail(&r->prod, prod_head, prod_next, is_sp);
482 end:
483  if (free_space != NULL)
484  *free_space = free_entries - n;
485  return n;
486 }
487 
511 static __rte_always_inline unsigned int
512 __rte_ring_move_cons_head(struct rte_ring *r, int is_sc,
513  unsigned int n, enum rte_ring_queue_behavior behavior,
514  uint32_t *old_head, uint32_t *new_head,
515  uint32_t *entries)
516 {
517  unsigned int max = n;
518  int success;
519 
520  /* move cons.head atomically */
521  do {
522  /* Restore n as it may change every loop */
523  n = max;
524 
525  *old_head = r->cons.head;
526 
527  /* add rmb barrier to avoid load/load reorder in weak
528  * memory model. It is noop on x86
529  */
530  rte_smp_rmb();
531 
532  const uint32_t prod_tail = r->prod.tail;
533  /* The subtraction is done between two unsigned 32bits value
534  * (the result is always modulo 32 bits even if we have
535  * cons_head > prod_tail). So 'entries' is always between 0
536  * and size(ring)-1. */
537  *entries = (prod_tail - *old_head);
538 
539  /* Set the actual entries for dequeue */
540  if (n > *entries)
541  n = (behavior == RTE_RING_QUEUE_FIXED) ? 0 : *entries;
542 
543  if (unlikely(n == 0))
544  return 0;
545 
546  *new_head = *old_head + n;
547  if (is_sc)
548  r->cons.head = *new_head, success = 1;
549  else
550  success = rte_atomic32_cmpset(&r->cons.head, *old_head,
551  *new_head);
552  } while (unlikely(success == 0));
553  return n;
554 }
555 
576 static __rte_always_inline unsigned int
577 __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table,
578  unsigned int n, enum rte_ring_queue_behavior behavior,
579  int is_sc, unsigned int *available)
580 {
581  uint32_t cons_head, cons_next;
582  uint32_t entries;
583 
584  n = __rte_ring_move_cons_head(r, is_sc, n, behavior,
585  &cons_head, &cons_next, &entries);
586  if (n == 0)
587  goto end;
588 
589  DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n, void *);
590  rte_smp_rmb();
591 
592  update_tail(&r->cons, cons_head, cons_next, is_sc);
593 
594 end:
595  if (available != NULL)
596  *available = entries - n;
597  return n;
598 }
599 
618 static __rte_always_inline unsigned int
619 rte_ring_mp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
620  unsigned int n, unsigned int *free_space)
621 {
622  return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
623  __IS_MP, free_space);
624 }
625 
641 static __rte_always_inline unsigned int
642 rte_ring_sp_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
643  unsigned int n, unsigned int *free_space)
644 {
645  return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
646  __IS_SP, free_space);
647 }
648 
668 static __rte_always_inline unsigned int
669 rte_ring_enqueue_bulk(struct rte_ring *r, void * const *obj_table,
670  unsigned int n, unsigned int *free_space)
671 {
672  return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
673  r->prod.single, free_space);
674 }
675 
690 static __rte_always_inline int
691 rte_ring_mp_enqueue(struct rte_ring *r, void *obj)
692 {
693  return rte_ring_mp_enqueue_bulk(r, &obj, 1, NULL) ? 0 : -ENOBUFS;
694 }
695 
707 static __rte_always_inline int
708 rte_ring_sp_enqueue(struct rte_ring *r, void *obj)
709 {
710  return rte_ring_sp_enqueue_bulk(r, &obj, 1, NULL) ? 0 : -ENOBUFS;
711 }
712 
728 static __rte_always_inline int
729 rte_ring_enqueue(struct rte_ring *r, void *obj)
730 {
731  return rte_ring_enqueue_bulk(r, &obj, 1, NULL) ? 0 : -ENOBUFS;
732 }
733 
752 static __rte_always_inline unsigned int
753 rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table,
754  unsigned int n, unsigned int *available)
755 {
756  return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
757  __IS_MC, available);
758 }
759 
776 static __rte_always_inline unsigned int
777 rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table,
778  unsigned int n, unsigned int *available)
779 {
780  return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
781  __IS_SC, available);
782 }
783 
803 static __rte_always_inline unsigned int
804 rte_ring_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n,
805  unsigned int *available)
806 {
807  return __rte_ring_do_dequeue(r, obj_table, n, RTE_RING_QUEUE_FIXED,
808  r->cons.single, available);
809 }
810 
826 static __rte_always_inline int
827 rte_ring_mc_dequeue(struct rte_ring *r, void **obj_p)
828 {
829  return rte_ring_mc_dequeue_bulk(r, obj_p, 1, NULL) ? 0 : -ENOENT;
830 }
831 
844 static __rte_always_inline int
845 rte_ring_sc_dequeue(struct rte_ring *r, void **obj_p)
846 {
847  return rte_ring_sc_dequeue_bulk(r, obj_p, 1, NULL) ? 0 : -ENOENT;
848 }
849 
866 static __rte_always_inline int
867 rte_ring_dequeue(struct rte_ring *r, void **obj_p)
868 {
869  return rte_ring_dequeue_bulk(r, obj_p, 1, NULL) ? 0 : -ENOENT;
870 }
871 
880 static inline unsigned
881 rte_ring_count(const struct rte_ring *r)
882 {
883  uint32_t prod_tail = r->prod.tail;
884  uint32_t cons_tail = r->cons.tail;
885  uint32_t count = (prod_tail - cons_tail) & r->mask;
886  return (count > r->capacity) ? r->capacity : count;
887 }
888 
897 static inline unsigned
899 {
900  return r->capacity - rte_ring_count(r);
901 }
902 
912 static inline int
913 rte_ring_full(const struct rte_ring *r)
914 {
915  return rte_ring_free_count(r) == 0;
916 }
917 
927 static inline int
928 rte_ring_empty(const struct rte_ring *r)
929 {
930  return rte_ring_count(r) == 0;
931 }
932 
943 static inline unsigned int
944 rte_ring_get_size(const struct rte_ring *r)
945 {
946  return r->size;
947 }
948 
957 static inline unsigned int
959 {
960  return r->capacity;
961 }
962 
969 void rte_ring_list_dump(FILE *f);
970 
981 struct rte_ring *rte_ring_lookup(const char *name);
982 
1001 static __rte_always_inline unsigned
1002 rte_ring_mp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
1003  unsigned int n, unsigned int *free_space)
1004 {
1005  return __rte_ring_do_enqueue(r, obj_table, n,
1006  RTE_RING_QUEUE_VARIABLE, __IS_MP, free_space);
1007 }
1008 
1024 static __rte_always_inline unsigned
1025 rte_ring_sp_enqueue_burst(struct rte_ring *r, void * const *obj_table,
1026  unsigned int n, unsigned int *free_space)
1027 {
1028  return __rte_ring_do_enqueue(r, obj_table, n,
1029  RTE_RING_QUEUE_VARIABLE, __IS_SP, free_space);
1030 }
1031 
1051 static __rte_always_inline unsigned
1052 rte_ring_enqueue_burst(struct rte_ring *r, void * const *obj_table,
1053  unsigned int n, unsigned int *free_space)
1054 {
1055  return __rte_ring_do_enqueue(r, obj_table, n, RTE_RING_QUEUE_VARIABLE,
1056  r->prod.single, free_space);
1057 }
1058 
1079 static __rte_always_inline unsigned
1080 rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table,
1081  unsigned int n, unsigned int *available)
1082 {
1083  return __rte_ring_do_dequeue(r, obj_table, n,
1084  RTE_RING_QUEUE_VARIABLE, __IS_MC, available);
1085 }
1086 
1104 static __rte_always_inline unsigned
1105 rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table,
1106  unsigned int n, unsigned int *available)
1107 {
1108  return __rte_ring_do_dequeue(r, obj_table, n,
1109  RTE_RING_QUEUE_VARIABLE, __IS_SC, available);
1110 }
1111 
1131 static __rte_always_inline unsigned
1132 rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table,
1133  unsigned int n, unsigned int *available)
1134 {
1135  return __rte_ring_do_dequeue(r, obj_table, n,
1136  RTE_RING_QUEUE_VARIABLE,
1137  r->cons.single, available);
1138 }
1139 
1140 #ifdef __cplusplus
1141 }
1142 #endif
1143 
1144 #endif /* _RTE_RING_H_ */
static void rte_smp_rmb(void)
static int rte_atomic32_cmpset(volatile uint32_t *dst, uint32_t exp, uint32_t src)
#define __rte_always_inline
Definition: rte_common.h:137
const struct rte_memzone * memzone
Definition: rte_ring.h:153
static __rte_always_inline unsigned int rte_ring_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:669
int flags
Definition: rte_ring.h:152
char name [RTE_MEMZONE_NAMESIZE] __rte_cache_aligned
Definition: rte_ring.h:151
static __rte_always_inline int rte_ring_dequeue(struct rte_ring *r, void **obj_p)
Definition: rte_ring.h:867
static __rte_always_inline unsigned rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:1080
struct rte_ring_headtail prod __rte_aligned(PROD_ALIGN)
static int rte_ring_empty(const struct rte_ring *r)
Definition: rte_ring.h:928
static __rte_always_inline unsigned rte_ring_mp_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:1002
static __rte_always_inline int rte_ring_mc_dequeue(struct rte_ring *r, void **obj_p)
Definition: rte_ring.h:827
void rte_ring_list_dump(FILE *f)
static __rte_always_inline unsigned int rte_ring_mp_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:619
#define unlikely(x)
static __rte_always_inline int rte_ring_sp_enqueue(struct rte_ring *r, void *obj)
Definition: rte_ring.h:708
static __rte_always_inline int rte_ring_mp_enqueue(struct rte_ring *r, void *obj)
Definition: rte_ring.h:691
static unsigned int rte_ring_get_capacity(const struct rte_ring *r)
Definition: rte_ring.h:958
static unsigned int rte_ring_get_size(const struct rte_ring *r)
Definition: rte_ring.h:944
static __rte_always_inline int rte_ring_sc_dequeue(struct rte_ring *r, void **obj_p)
Definition: rte_ring.h:845
uint32_t size
Definition: rte_ring.h:155
void rte_ring_free(struct rte_ring *r)
static void rte_pause(void)
static __rte_always_inline unsigned rte_ring_sp_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:1025
static void rte_smp_wmb(void)
static __rte_always_inline unsigned rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:1105
static __rte_always_inline unsigned rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:1132
static __rte_always_inline unsigned int rte_ring_sp_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:642
void rte_ring_dump(FILE *f, const struct rte_ring *r)
static unsigned rte_ring_count(const struct rte_ring *r)
Definition: rte_ring.h:881
uint32_t mask
Definition: rte_ring.h:156
struct rte_ring * rte_ring_create(const char *name, unsigned count, int socket_id, unsigned flags)
static __rte_always_inline unsigned int rte_ring_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:804
static __rte_always_inline unsigned int rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:777
struct rte_ring * rte_ring_lookup(const char *name)
uint32_t capacity
Definition: rte_ring.h:157
static unsigned rte_ring_free_count(const struct rte_ring *r)
Definition: rte_ring.h:898
static __rte_always_inline int rte_ring_enqueue(struct rte_ring *r, void *obj)
Definition: rte_ring.h:729
static __rte_always_inline unsigned rte_ring_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
Definition: rte_ring.h:1052
static __rte_always_inline unsigned int rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
Definition: rte_ring.h:753
int rte_ring_init(struct rte_ring *r, const char *name, unsigned count, unsigned flags)
static int rte_ring_full(const struct rte_ring *r)
Definition: rte_ring.h:913
ssize_t rte_ring_get_memsize(unsigned count)
#define RTE_MEMZONE_NAMESIZE
Definition: rte_memzone.h:78