10#ifndef _RTE_RING_RTS_ELEM_PVT_H_
11#define _RTE_RING_RTS_ELEM_PVT_H_
25__rte_ring_rts_update_tail(
struct rte_ring_rts_headtail *ht)
27 union __rte_ring_rts_poscnt h, ot, nt;
45 ot.raw = __atomic_load_n(&ht->tail.raw, __ATOMIC_ACQUIRE);
49 h.raw = __atomic_load_n(&ht->head.raw, __ATOMIC_RELAXED);
52 if (++nt.val.cnt == h.val.cnt)
53 nt.val.pos = h.val.pos;
59 }
while (__atomic_compare_exchange_n(&ht->tail.raw, &ot.raw, nt.raw,
60 0, __ATOMIC_RELEASE, __ATOMIC_ACQUIRE) == 0);
68__rte_ring_rts_head_wait(const struct rte_ring_rts_headtail *ht,
71 union __rte_ring_rts_poscnt h;
72 uint32_t max = ht->htd_max;
75 h.raw = __atomic_load_n(&ht->head.raw, memorder);
77 while (h.val.pos - ht->tail.val.pos > max) {
79 h.raw = __atomic_load_n(&ht->head.raw, memorder);
89__rte_ring_rts_move_prod_head(
struct rte_ring *r, uint32_t num,
91 uint32_t *free_entries)
93 uint32_t n, cons_tail;
94 union __rte_ring_rts_poscnt nh, oh;
96 const uint32_t capacity = r->
capacity;
113 oh = __rte_ring_rts_head_wait(&r->rts_prod, __ATOMIC_ACQUIRE);
120 cons_tail = __atomic_load_n(&r->cons.
tail, __ATOMIC_ACQUIRE);
128 *free_entries = capacity + cons_tail - oh.val.pos;
138 nh.val.pos = oh.val.pos + n;
139 nh.val.cnt = oh.val.cnt + 1;
149 }
while (__atomic_compare_exchange_n(&r->rts_prod.head.raw,
151 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED) == 0);
153 *old_head = oh.val.pos;
161__rte_ring_rts_move_cons_head(
struct rte_ring *r, uint32_t num,
165 uint32_t n, prod_tail;
166 union __rte_ring_rts_poscnt nh, oh;
184 oh = __rte_ring_rts_head_wait(&r->rts_cons, __ATOMIC_ACQUIRE);
191 prod_tail = __atomic_load_n(&r->prod.
tail, __ATOMIC_ACQUIRE);
198 *entries = prod_tail - oh.val.pos;
207 nh.val.pos = oh.val.pos + n;
208 nh.val.cnt = oh.val.cnt + 1;
218 }
while (__atomic_compare_exchange_n(&r->rts_cons.head.raw,
220 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED) == 0);
222 *old_head = oh.val.pos;
249__rte_ring_do_rts_enqueue_elem(
struct rte_ring *r,
const void *obj_table,
251 uint32_t *free_space)
255 n = __rte_ring_rts_move_prod_head(r, n, behavior, &head, &free);
258 __rte_ring_enqueue_elems(r, head, obj_table, esize, n);
259 __rte_ring_rts_update_tail(&r->rts_prod);
262 if (free_space != NULL)
263 *free_space = free - n;
290__rte_ring_do_rts_dequeue_elem(
struct rte_ring *r,
void *obj_table,
294 uint32_t entries, head;
296 n = __rte_ring_rts_move_cons_head(r, n, behavior, &head, &entries);
299 __rte_ring_dequeue_elems(r, head, obj_table, esize, n);
300 __rte_ring_rts_update_tail(&r->rts_cons);
303 if (available != NULL)
304 *available = entries - n;
#define __rte_always_inline
static void rte_pause(void)