Lines Matching refs:ring
66 void rds_ib_ring_init(struct rds_ib_work_ring *ring, u32 nr) in rds_ib_ring_init() argument
68 memset(ring, 0, sizeof(*ring)); in rds_ib_ring_init()
69 ring->w_nr = nr; in rds_ib_ring_init()
70 rdsdebug("ring %p nr %u\n", ring, ring->w_nr); in rds_ib_ring_init()
73 static inline u32 __rds_ib_ring_used(struct rds_ib_work_ring *ring) in __rds_ib_ring_used() argument
78 diff = ring->w_alloc_ctr - (u32) atomic_read(&ring->w_free_ctr); in __rds_ib_ring_used()
79 BUG_ON(diff > ring->w_nr); in __rds_ib_ring_used()
84 void rds_ib_ring_resize(struct rds_ib_work_ring *ring, u32 nr) in rds_ib_ring_resize() argument
88 BUG_ON(__rds_ib_ring_used(ring)); in rds_ib_ring_resize()
89 ring->w_nr = nr; in rds_ib_ring_resize()
92 static int __rds_ib_ring_empty(struct rds_ib_work_ring *ring) in __rds_ib_ring_empty() argument
94 return __rds_ib_ring_used(ring) == 0; in __rds_ib_ring_empty()
97 u32 rds_ib_ring_alloc(struct rds_ib_work_ring *ring, u32 val, u32 *pos) in rds_ib_ring_alloc() argument
101 avail = ring->w_nr - __rds_ib_ring_used(ring); in rds_ib_ring_alloc()
103 rdsdebug("ring %p val %u next %u free %u\n", ring, val, in rds_ib_ring_alloc()
104 ring->w_alloc_ptr, avail); in rds_ib_ring_alloc()
108 *pos = ring->w_alloc_ptr; in rds_ib_ring_alloc()
110 ring->w_alloc_ptr = (ring->w_alloc_ptr + ret) % ring->w_nr; in rds_ib_ring_alloc()
111 ring->w_alloc_ctr += ret; in rds_ib_ring_alloc()
117 void rds_ib_ring_free(struct rds_ib_work_ring *ring, u32 val) in rds_ib_ring_free() argument
119 ring->w_free_ptr = (ring->w_free_ptr + val) % ring->w_nr; in rds_ib_ring_free()
120 atomic_add(val, &ring->w_free_ctr); in rds_ib_ring_free()
122 if (__rds_ib_ring_empty(ring) && in rds_ib_ring_free()
127 void rds_ib_ring_unalloc(struct rds_ib_work_ring *ring, u32 val) in rds_ib_ring_unalloc() argument
129 ring->w_alloc_ptr = (ring->w_alloc_ptr - val) % ring->w_nr; in rds_ib_ring_unalloc()
130 ring->w_alloc_ctr -= val; in rds_ib_ring_unalloc()
133 int rds_ib_ring_empty(struct rds_ib_work_ring *ring) in rds_ib_ring_empty() argument
135 return __rds_ib_ring_empty(ring); in rds_ib_ring_empty()
138 int rds_ib_ring_low(struct rds_ib_work_ring *ring) in rds_ib_ring_low() argument
140 return __rds_ib_ring_used(ring) <= (ring->w_nr >> 1); in rds_ib_ring_low()
147 u32 rds_ib_ring_oldest(struct rds_ib_work_ring *ring) in rds_ib_ring_oldest() argument
149 return ring->w_free_ptr; in rds_ib_ring_oldest()
156 u32 rds_ib_ring_completed(struct rds_ib_work_ring *ring, u32 wr_id, u32 oldest) in rds_ib_ring_completed() argument
163 ret = ring->w_nr - oldest + (unsigned long long)wr_id + 1; in rds_ib_ring_completed()
165 rdsdebug("ring %p ret %u wr_id %u oldest %u\n", ring, ret, in rds_ib_ring_completed()