X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_ring%2Frte_ring.h;fp=lib%2Flibrte_ring%2Frte_ring.h;h=3e013ad4ce1e53316c277cffc1e9f022a0939bbd;hb=6a68df7f230fe6908da4c1a4af42f55f185a23e9;hp=fa66638055a0c7022a24caf50955bcf4bb9c696a;hpb=0dfc98c507b15bc32671fa047504e2dd7107e94c;p=dpdk.git diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h index fa66638055..3e013ad4ce 100644 --- a/lib/librte_ring/rte_ring.h +++ b/lib/librte_ring/rte_ring.h @@ -341,6 +341,21 @@ void rte_ring_dump(FILE *f, const struct rte_ring *r); } \ } while (0) +static inline __attribute__((always_inline)) void +update_tail(struct rte_ring_headtail *ht, uint32_t old_val, uint32_t new_val, + uint32_t single) +{ + /* + * If there are other enqueues/dequeues in progress that preceded us, + * we need to wait for them to complete + */ + if (!single) + while (unlikely(ht->tail != old_val)) + rte_pause(); + + ht->tail = new_val; +} + /** * @internal This function updates the producer head for enqueue * @@ -440,15 +455,7 @@ __rte_ring_do_enqueue(struct rte_ring *r, void * const *obj_table, ENQUEUE_PTRS(); rte_smp_wmb(); - /* - * If there are other enqueues in progress that preceded us, - * we need to wait for them to complete - */ - while (unlikely(r->prod.tail != prod_head)) - rte_pause(); - - r->prod.tail = prod_next; - + update_tail(&r->prod, prod_head, prod_next, is_sp); end: if (free_space != NULL) *free_space = free_entries - n; @@ -553,14 +560,7 @@ __rte_ring_do_dequeue(struct rte_ring *r, void **obj_table, DEQUEUE_PTRS(); rte_smp_rmb(); - /* - * If there are other enqueues in progress that preceded us, - * we need to wait for them to complete - */ - while (unlikely(r->cons.tail != cons_head)) - rte_pause(); - - r->cons.tail = cons_next; + update_tail(&r->cons, cons_head, cons_next, is_sc); end: if (available != NULL)