diff options
author | kmacy <kmacy@FreeBSD.org> | 2008-01-13 22:37:09 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2008-01-13 22:37:09 +0000 |
commit | 09452a19b0d7f1e2af0ad3730ea621217dc4a117 (patch) | |
tree | 49bcfb28fce5a0abef7c59e841e10d0f506ef2ad /sys/dev/cxgb | |
parent | 1c6521cfbbcbf64188814f51ece74586839bd0d2 (diff) | |
download | FreeBSD-src-09452a19b0d7f1e2af0ad3730ea621217dc4a117.zip FreeBSD-src-09452a19b0d7f1e2af0ad3730ea621217dc4a117.tar.gz |
Add buf_ring_full utility function, make sure dequeue/enqueue see the latest
indexes
Diffstat (limited to 'sys/dev/cxgb')
-rw-r--r-- | sys/dev/cxgb/cxgb_osdep.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/dev/cxgb/cxgb_osdep.h b/sys/dev/cxgb/cxgb_osdep.h index 7f75779..3a0b774 100644 --- a/sys/dev/cxgb/cxgb_osdep.h +++ b/sys/dev/cxgb/cxgb_osdep.h @@ -203,6 +203,12 @@ buf_ring_empty(struct buf_ring *mr) return (mr->br_cons == mr->br_prod); } +static __inline int +buf_ring_full(struct buf_ring *mr) +{ + return (mr->br_cons == (mr->br_prod + 1)); +} + /* * The producer and consumer are independently locked * this relies on the consumer providing his own serialization @@ -217,6 +223,7 @@ buf_ring_dequeue(struct buf_ring *mr) ring = (caddr_t *)mr->br_ring; mask = mr->br_size - 1; cons = mr->br_cons; + mb(); prod = mr->br_prod; m = NULL; if (cons != prod) { @@ -234,9 +241,10 @@ __buf_ring_enqueue(struct buf_ring *mr, void *m) int prod, cons, mask, err; - cons = mr->br_cons; - prod = mr->br_prod; mask = mr->br_size - 1; + prod = mr->br_prod; + mb(); + cons = mr->br_cons; if (((prod + 1) & mask) != cons) { mr->br_ring[prod] = m; mb(); |