173 int socket_id,
unsigned flags);
196 #define ENQUEUE_PTRS(r, ring_start, prod_head, obj_table, n, obj_type) do { \
198 const uint32_t size = (r)->size; \
199 uint32_t idx = prod_head & (r)->mask; \
200 obj_type *ring = (obj_type *)ring_start; \
201 if (likely(idx + n < size)) { \
202 for (i = 0; i < (n & ((~(unsigned)0x3))); i+=4, idx+=4) { \
203 ring[idx] = obj_table[i]; \
204 ring[idx+1] = obj_table[i+1]; \
205 ring[idx+2] = obj_table[i+2]; \
206 ring[idx+3] = obj_table[i+3]; \
210 ring[idx++] = obj_table[i++]; \
212 ring[idx++] = obj_table[i++]; \
214 ring[idx++] = obj_table[i++]; \
217 for (i = 0; idx < size; i++, idx++)\
218 ring[idx] = obj_table[i]; \
219 for (idx = 0; i < n; i++, idx++) \
220 ring[idx] = obj_table[i]; \
227 #define DEQUEUE_PTRS(r, ring_start, cons_head, obj_table, n, obj_type) do { \
229 uint32_t idx = cons_head & (r)->mask; \
230 const uint32_t size = (r)->size; \
231 obj_type *ring = (obj_type *)ring_start; \
232 if (likely(idx + n < size)) { \
233 for (i = 0; i < (n & (~(unsigned)0x3)); i+=4, idx+=4) {\
234 obj_table[i] = ring[idx]; \
235 obj_table[i+1] = ring[idx+1]; \
236 obj_table[i+2] = ring[idx+2]; \
237 obj_table[i+3] = ring[idx+3]; \
241 obj_table[i++] = ring[idx++]; \
243 obj_table[i++] = ring[idx++]; \
245 obj_table[i++] = ring[idx++]; \
248 for (i = 0; idx < size; i++, idx++) \
249 obj_table[i] = ring[idx]; \
250 for (idx = 0; i < n; i++, idx++) \
251 obj_table[i] = ring[idx]; \
264 #ifdef RTE_USE_C11_MEM_MODEL
265 #include "rte_ring_c11_mem.h"
267 #include "rte_ring_generic.h"
291 __rte_ring_do_enqueue(
struct rte_ring *r,
void *
const *obj_table,
293 unsigned int is_sp,
unsigned int *free_space)
295 uint32_t prod_head, prod_next;
296 uint32_t free_entries;
298 n = __rte_ring_move_prod_head(r, is_sp, n, behavior,
299 &prod_head, &prod_next, &free_entries);
303 ENQUEUE_PTRS(r, &r[1], prod_head, obj_table, n,
void *);
305 update_tail(&r->prod, prod_head, prod_next, is_sp, 1);
307 if (free_space != NULL)
308 *free_space = free_entries - n;
333 __rte_ring_do_dequeue(
struct rte_ring *r,
void **obj_table,
335 unsigned int is_sc,
unsigned int *available)
337 uint32_t cons_head, cons_next;
340 n = __rte_ring_move_cons_head(r, (
int)is_sc, n, behavior,
341 &cons_head, &cons_next, &entries);
345 DEQUEUE_PTRS(r, &r[1], cons_head, obj_table, n,
void *);
347 update_tail(&r->cons, cons_head, cons_next, is_sc, 0);
350 if (available != NULL)
351 *available = entries - n;
375 unsigned int n,
unsigned int *free_space)
398 unsigned int n,
unsigned int *free_space)
404 #ifdef ALLOW_EXPERIMENTAL_API
429 unsigned int n,
unsigned int *free_space)
436 #ifdef ALLOW_EXPERIMENTAL_API
437 case RTE_RING_SYNC_MT_RTS:
440 case RTE_RING_SYNC_MT_HTS:
529 unsigned int n,
unsigned int *available)
553 unsigned int n,
unsigned int *available)
580 unsigned int *available)
587 #ifdef ALLOW_EXPERIMENTAL_API
588 case RTE_RING_SYNC_MT_RTS:
590 case RTE_RING_SYNC_MT_HTS:
686 static inline unsigned
689 uint32_t prod_tail = r->prod.
tail;
690 uint32_t cons_tail = r->cons.
tail;
691 uint32_t count = (prod_tail - cons_tail) & r->
mask;
703 static inline unsigned
749 static inline unsigned int
763 static inline unsigned int
865 unsigned int n,
unsigned int *free_space)
867 return __rte_ring_do_enqueue(r, obj_table, n,
888 unsigned int n,
unsigned int *free_space)
890 return __rte_ring_do_enqueue(r, obj_table, n,
915 unsigned int n,
unsigned int *free_space)
922 #ifdef ALLOW_EXPERIMENTAL_API
923 case RTE_RING_SYNC_MT_RTS:
926 case RTE_RING_SYNC_MT_HTS:
959 unsigned int n,
unsigned int *available)
961 return __rte_ring_do_dequeue(r, obj_table, n,
984 unsigned int n,
unsigned int *available)
986 return __rte_ring_do_dequeue(r, obj_table, n,
1011 unsigned int n,
unsigned int *available)
1018 #ifdef ALLOW_EXPERIMENTAL_API
1019 case RTE_RING_SYNC_MT_RTS:
1022 case RTE_RING_SYNC_MT_HTS:
static __rte_experimental __rte_always_inline unsigned int rte_ring_mc_rts_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
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)
#define __rte_always_inline
static __rte_experimental __rte_always_inline unsigned rte_ring_mc_rts_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
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)
static enum rte_ring_sync_type rte_ring_get_prod_sync_type(const struct rte_ring *r)
static __rte_always_inline int rte_ring_dequeue(struct rte_ring *r, void **obj_p)
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)
static __rte_always_inline unsigned rte_ring_mc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
static int rte_ring_empty(const struct rte_ring *r)
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)
static __rte_experimental __rte_always_inline unsigned rte_ring_mc_hts_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
static __rte_always_inline int rte_ring_mc_dequeue(struct rte_ring *r, void **obj_p)
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)
static __rte_experimental __rte_always_inline unsigned rte_ring_mp_rts_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
static __rte_always_inline int rte_ring_sp_enqueue(struct rte_ring *r, void *obj)
static __rte_always_inline int rte_ring_mp_enqueue(struct rte_ring *r, void *obj)
static unsigned int rte_ring_get_capacity(const struct rte_ring *r)
static int rte_ring_is_cons_single(const struct rte_ring *r)
static unsigned int rte_ring_get_size(const struct rte_ring *r)
static __rte_always_inline int rte_ring_sc_dequeue(struct rte_ring *r, void **obj_p)
void rte_ring_free(struct rte_ring *r)
static __rte_experimental __rte_always_inline unsigned rte_ring_mp_hts_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
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)
static __rte_always_inline unsigned rte_ring_sc_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
static __rte_experimental __rte_always_inline unsigned int rte_ring_mp_rts_enqueue_bulk(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
static int rte_ring_is_prod_single(const struct rte_ring *r)
static __rte_always_inline unsigned rte_ring_dequeue_burst(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
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)
void rte_ring_dump(FILE *f, const struct rte_ring *r)
static unsigned rte_ring_count(const struct rte_ring *r)
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)
static enum rte_ring_sync_type rte_ring_get_cons_sync_type(const struct rte_ring *r)
static __rte_always_inline unsigned int rte_ring_sc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
struct rte_ring * rte_ring_lookup(const char *name)
enum rte_ring_sync_type sync_type
static unsigned rte_ring_free_count(const struct rte_ring *r)
static __rte_always_inline int rte_ring_enqueue(struct rte_ring *r, void *obj)
static __rte_always_inline unsigned rte_ring_enqueue_burst(struct rte_ring *r, void *const *obj_table, unsigned int n, unsigned int *free_space)
__rte_experimental void rte_ring_reset(struct rte_ring *r)
static __rte_always_inline unsigned int rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned int n, unsigned int *available)
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)
ssize_t rte_ring_get_memsize(unsigned count)