Date: Sat, 29 Sep 2007 22:36:15 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 126993 for review Message-ID: <200709292236.l8TMaFhu050611@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=126993 Change 126993 by kmacy@kmacy_home:ethng on 2007/09/29 22:35:49 move mbuf ring definitions to after memory barrier definitions Affected files ... .. //depot/projects/ethng/src/sys/dev/cxgb/cxgb_osdep.h#12 edit Differences ... ==== //depot/projects/ethng/src/sys/dev/cxgb/cxgb_osdep.h#12 (text+ko) ==== @@ -61,65 +61,6 @@ struct mbuf *mh_tail; }; -struct mbuf_ring { - struct mbuf **mr_ring; - volatile uint32_t mr_cons; - volatile uint32_t mr_prod; - int mr_size; - struct mtx mr_lock; -}; - -static __inline int -mbuf_ring_count(struct mbuf_ring *mr) -{ - int size = mr->mr_size; - int mask = size - 1; - - return ((size + mr->mr_prod - mr->mr_cons) & mask); -} - -static __inline int -mbuf_ring_empty(struct mbuf_ring *mr) -{ - return (mr->mr_cons == mr->mr_prod); -} - -static __inline struct mbuf * -mbuf_ring_dequeue(struct mbuf_ring *mr) -{ - int prod, cons, mask; - struct mbuf **ring, *m; - - ring = mr->mr_ring; - mask = mr->mr_size - 1; - cons = mr->mr_cons; - prod = mr->mr_prod; - m = NULL; - if (cons != prod) { - m = ring[cons]; - mr->mr_cons = (cons + 1) & mask; - } - - return (m); -} - -static __inline struct mbuf * -mbuf_ring_peek(struct mbuf_ring *mr) -{ - int prod, cons, mask; - struct mbuf **ring, *m; - - ring = mr->mr_ring; - mask = mr->mr_size - 1; - cons = mr->mr_cons; - prod = mr->mr_prod; - m = NULL; - if (cons != prod) - m = ring[cons]; - - return (m); -} - #define PANIC_IF(exp) do { \ if (exp) \ panic("BUG: %s", exp); \ @@ -221,6 +162,67 @@ #define prefetch(x) #define L1_CACHE_BYTES 32 #endif + +struct mbuf_ring { + struct mbuf **mr_ring; + volatile uint32_t mr_cons; + volatile uint32_t mr_prod; + int mr_size; + struct mtx mr_lock; +}; + +static __inline int +mbuf_ring_count(struct mbuf_ring *mr) +{ + int size = mr->mr_size; + int mask = size - 1; + + return ((size + mr->mr_prod - mr->mr_cons) & mask); +} + +static __inline int +mbuf_ring_empty(struct mbuf_ring *mr) +{ + return (mr->mr_cons == mr->mr_prod); +} + +static __inline struct mbuf * +mbuf_ring_dequeue(struct mbuf_ring *mr) +{ + int prod, cons, mask; + struct mbuf **ring, *m; + + ring = mr->mr_ring; + mask = mr->mr_size - 1; + cons = mr->mr_cons; + prod = mr->mr_prod; + m = NULL; + if (cons != prod) { + m = ring[cons]; + mr->mr_cons = (cons + 1) & mask; + mb(); + } + + return (m); +} + +static __inline struct mbuf * +mbuf_ring_peek(struct mbuf_ring *mr) +{ + int prod, cons, mask; + struct mbuf **ring, *m; + + ring = mr->mr_ring; + mask = mr->mr_size - 1; + cons = mr->mr_cons; + prod = mr->mr_prod; + m = NULL; + if (cons != prod) + m = ring[cons]; + + return (m); +} + #define DBG_RX (1 << 0) static const int debug_flags = DBG_RX; @@ -245,7 +247,6 @@ #define test_and_clear_bit(bit, p) atomic_cmpset_int((p), ((*(p)) | bit), ((*(p)) & ~bit)) - #define max_t(type, a, b) (type)max((a), (b)) #define net_device ifnet #define cpu_to_be32 htobe32
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200709292236.l8TMaFhu050611>