10#ifndef _RTE_RING_HTS_ELEM_PVT_H_
11#define _RTE_RING_HTS_ELEM_PVT_H_
25__rte_ring_hts_update_tail(
struct rte_ring_hts_headtail *ht, uint32_t old_tail,
26 uint32_t num, uint32_t enqueue)
32 tail = old_tail + num;
40 __atomic_store_n(&ht->ht.pos.tail, tail, __ATOMIC_RELEASE);
55__rte_ring_hts_head_wait(const struct rte_ring_hts_headtail *ht,
58 union __rte_ring_hts_pos p;
59 p.raw = __atomic_load_n(&ht->ht.raw, memorder);
61 while (p.pos.head != p.pos.tail) {
63 p.raw = __atomic_load_n(&ht->ht.raw, memorder);
73__rte_ring_hts_move_prod_head(
struct rte_ring *r,
unsigned int num,
75 uint32_t *free_entries)
77 uint32_t n, cons_tail;
78 union __rte_ring_hts_pos np, op;
80 const uint32_t capacity = r->
capacity;
97 op = __rte_ring_hts_head_wait(&r->hts_prod, __ATOMIC_ACQUIRE);
104 cons_tail = __atomic_load_n(&r->cons.
tail, __ATOMIC_ACQUIRE);
112 *free_entries = capacity + cons_tail - op.pos.head;
122 np.pos.tail = op.pos.tail;
123 np.pos.head = op.pos.head + n;
133 }
while (__atomic_compare_exchange_n(&r->hts_prod.ht.raw,
135 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED) == 0);
137 *old_head = op.pos.head;
145__rte_ring_hts_move_cons_head(
struct rte_ring *r,
unsigned int num,
149 uint32_t n, prod_tail;
150 union __rte_ring_hts_pos np, op;
168 op = __rte_ring_hts_head_wait(&r->hts_cons, __ATOMIC_ACQUIRE);
175 prod_tail = __atomic_load_n(&r->prod.
tail, __ATOMIC_ACQUIRE);
182 *entries = prod_tail - op.pos.head;
191 np.pos.tail = op.pos.tail;
192 np.pos.head = op.pos.head + n;
202 }
while (__atomic_compare_exchange_n(&r->hts_cons.ht.raw,
204 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED) == 0);
206 *old_head = op.pos.head;
233__rte_ring_do_hts_enqueue_elem(
struct rte_ring *r,
const void *obj_table,
235 uint32_t *free_space)
239 n = __rte_ring_hts_move_prod_head(r, n, behavior, &head, &free);
242 __rte_ring_enqueue_elems(r, head, obj_table, esize, n);
243 __rte_ring_hts_update_tail(&r->hts_prod, head, n, 1);
246 if (free_space != NULL)
247 *free_space = free - n;
274__rte_ring_do_hts_dequeue_elem(
struct rte_ring *r,
void *obj_table,
278 uint32_t entries, head;
280 n = __rte_ring_hts_move_cons_head(r, n, behavior, &head, &entries);
283 __rte_ring_dequeue_elems(r, head, obj_table, esize, n);
284 __rte_ring_hts_update_tail(&r->hts_cons, head, n, 0);
287 if (available != NULL)
288 *available = entries - n;
#define __rte_always_inline
static void rte_pause(void)