Lines Matching refs:br

76 buf_ring_enqueue(struct buf_ring *br, void *buf)
83 for (i = br->br_cons_head; i != br->br_prod_head;
84 i = ((i + 1) & br->br_cons_mask))
85 if(br->br_ring[i] == buf)
87 buf, i, br->br_prod_tail, br->br_cons_tail);
91 prod_head = br->br_prod_head;
92 cons_tail = br->br_cons_tail;
94 prod_next = (prod_head + 1) & br->br_prod_mask;
97 br->br_drops++;
102 success = atomic_cmpset_int(&br->br_prod_head, prod_head,
106 if (br->br_ring[prod_head] != NULL)
109 br->br_ring[prod_head] = buf;
117 while (br->br_prod_tail != prod_head)
119 br->br_prod_bufs++;
120 br->br_prod_tail = prod_next;
130 buf_ring_dequeue_mc(struct buf_ring *br)
139 cons_head = br->br_cons_head;
140 prod_tail = br->br_prod_tail;
142 cons_next = (cons_head + 1) & br->br_cons_mask;
149 success = atomic_cmpset_int(&br->br_cons_head, cons_head,
153 buf = br->br_ring[cons_head];
155 br->br_ring[cons_head] = NULL;
164 while (br->br_cons_tail != cons_head)
167 br->br_cons_tail = cons_next;
179 buf_ring_dequeue_sc(struct buf_ring *br)
185 cons_head = br->br_cons_head;
186 prod_tail = br->br_prod_tail;
188 cons_next = (cons_head + 1) & br->br_cons_mask;
189 cons_next_next = (cons_head + 2) & br->br_cons_mask;
196 prefetch(br->br_ring[cons_next]);
198 prefetch(br->br_ring[cons_next_next]);
201 br->br_cons_head = cons_next;
202 buf = br->br_ring[cons_head];
205 br->br_ring[cons_head] = NULL;
206 if (!mtx_owned(br->br_lock))
208 if (br->br_cons_tail != cons_head)
210 br->br_cons_tail, cons_head);
212 br->br_cons_tail = cons_next;
222 buf_ring_advance_sc(struct buf_ring *br)
227 cons_head = br->br_cons_head;
228 prod_tail = br->br_prod_tail;
230 cons_next = (cons_head + 1) & br->br_cons_mask;
233 br->br_cons_head = cons_next;
235 br->br_ring[cons_head] = NULL;
237 br->br_cons_tail = cons_next;
257 buf_ring_putback_sc(struct buf_ring *br, void *new)
259 KASSERT(br->br_cons_head != br->br_prod_tail,
261 br->br_ring[br->br_cons_head] = new;
270 buf_ring_peek(struct buf_ring *br)
274 if ((br->br_lock != NULL) && !mtx_owned(br->br_lock))
283 if (br->br_cons_head == br->br_prod_tail)
286 return (br->br_ring[br->br_cons_head]);
290 buf_ring_full(struct buf_ring *br)
293 return (((br->br_prod_head + 1) & br->br_prod_mask) == br->br_cons_tail);
297 buf_ring_empty(struct buf_ring *br)
300 return (br->br_cons_head == br->br_prod_tail);
304 buf_ring_count(struct buf_ring *br)
307 return ((br->br_prod_size + br->br_prod_tail - br->br_cons_tail)
308 & br->br_prod_mask);
313 void buf_ring_free(struct buf_ring *br, struct malloc_type *type);