10#ifndef _RTE_RING_HTS_ELEM_PVT_H_
11#define _RTE_RING_HTS_ELEM_PVT_H_
13#include <rte_stdatomic.h>
27__rte_ring_hts_update_tail(
struct rte_ring_hts_headtail *ht, uint32_t old_tail,
28 uint32_t num, uint32_t enqueue)
34 tail = old_tail + num;
42 rte_atomic_store_explicit(&ht->ht.pos.tail, tail, rte_memory_order_release);
57__rte_ring_hts_head_wait(const struct rte_ring_hts_headtail *ht,
60 union __rte_ring_hts_pos p;
61 p.raw = rte_atomic_load_explicit(&ht->ht.raw, memorder);
63 while (p.pos.head != p.pos.tail) {
65 p.raw = rte_atomic_load_explicit(&ht->ht.raw, memorder);
75__rte_ring_hts_move_prod_head(
struct rte_ring *r,
unsigned int num,
77 uint32_t *free_entries)
79 uint32_t n, cons_tail;
80 union __rte_ring_hts_pos np, op;
82 const uint32_t capacity = r->
capacity;
99 op = __rte_ring_hts_head_wait(&r->hts_prod, rte_memory_order_acquire);
106 cons_tail = rte_atomic_load_explicit(&r->cons.tail, rte_memory_order_acquire);
114 *free_entries = capacity + cons_tail - op.pos.head;
124 np.pos.tail = op.pos.tail;
125 np.pos.head = op.pos.head + n;
135 }
while (rte_atomic_compare_exchange_strong_explicit(&r->hts_prod.ht.raw,
136 (uint64_t *)(uintptr_t)&op.raw, np.raw,
137 rte_memory_order_release, rte_memory_order_relaxed) == 0);
139 *old_head = op.pos.head;
147__rte_ring_hts_move_cons_head(
struct rte_ring *r,
unsigned int num,
151 uint32_t n, prod_tail;
152 union __rte_ring_hts_pos np, op;
170 op = __rte_ring_hts_head_wait(&r->hts_cons, rte_memory_order_acquire);
177 prod_tail = rte_atomic_load_explicit(&r->prod.tail, rte_memory_order_acquire);
184 *entries = prod_tail - op.pos.head;
193 np.pos.tail = op.pos.tail;
194 np.pos.head = op.pos.head + n;
204 }
while (rte_atomic_compare_exchange_strong_explicit(&r->hts_cons.ht.raw,
205 (uint64_t *)(uintptr_t)&op.raw, np.raw,
206 rte_memory_order_release, rte_memory_order_relaxed) == 0);
208 *old_head = op.pos.head;
235__rte_ring_do_hts_enqueue_elem(
struct rte_ring *r,
const void *obj_table,
237 uint32_t *free_space)
241 n = __rte_ring_hts_move_prod_head(r, n, behavior, &head, &free);
244 __rte_ring_enqueue_elems(r, head, obj_table, esize, n);
245 __rte_ring_hts_update_tail(&r->hts_prod, head, n, 1);
248 if (free_space != NULL)
249 *free_space = free - n;
276__rte_ring_do_hts_dequeue_elem(
struct rte_ring *r,
void *obj_table,
280 uint32_t entries, head;
282 n = __rte_ring_hts_move_cons_head(r, n, behavior, &head, &entries);
285 __rte_ring_dequeue_elems(r, head, obj_table, esize, n);
286 __rte_ring_hts_update_tail(&r->hts_cons, head, n, 0);
289 if (available != NULL)
290 *available = entries - n;
#define __rte_always_inline
static void rte_pause(void)