diff options
author | kmacy <kmacy@FreeBSD.org> | 2009-06-09 19:19:16 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2009-06-09 19:19:16 +0000 |
commit | 3f394b4e7809f55e44ba6dbd134af82530dc0479 (patch) | |
tree | 1e2846eb74a9a33c51ac9e7f59ecae32c4628e7c /sys/net/if_var.h | |
parent | 898dda825cfcffcc2b924756406dffce9cf7e252 (diff) | |
download | FreeBSD-src-3f394b4e7809f55e44ba6dbd134af82530dc0479.zip FreeBSD-src-3f394b4e7809f55e44ba6dbd134af82530dc0479.tar.gz |
- add drbr routines for accessing #qentries and conditionally dequeueing
- track bytes enqueued in buf_ring
Diffstat (limited to 'sys/net/if_var.h')
-rw-r--r-- | sys/net/if_var.h | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 2d0a0ab..375dbce 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -556,10 +556,11 @@ do { \ static __inline void drbr_stats_update(struct ifnet *ifp, int len, int mflags) { - +#ifndef NO_SLOW_STATS ifp->if_obytes += len; if (mflags & M_MCAST) ifp->if_omcasts++; +#endif } static __inline int @@ -575,9 +576,8 @@ drbr_enqueue(struct ifnet *ifp, struct buf_ring *br, struct mbuf *m) return (error); } #endif - if ((error = buf_ring_enqueue(br, m)) == ENOBUFS) { + if ((error = buf_ring_enqueue_bytes(br, m, len)) == ENOBUFS) { br->br_drops++; - _IF_DROP(&ifp->if_snd); m_freem(m); } else drbr_stats_update(ifp, len, mflags); @@ -610,6 +610,27 @@ drbr_dequeue(struct ifnet *ifp, struct buf_ring *br) return (buf_ring_dequeue_sc(br)); } +static __inline struct mbuf * +drbr_dequeue_cond(struct ifnet *ifp, struct buf_ring *br, + int (*func) (struct mbuf *, void *), void *arg) +{ + struct mbuf *m; +#ifdef ALTQ + /* + * XXX need to evaluate / requeue + */ + if (ALTQ_IS_ENABLED(&ifp->if_snd)) { + IFQ_DRV_DEQUEUE(&ifp->if_snd, m); + return (m); + } +#endif + m = buf_ring_peek(br); + if (m == NULL || func(m, arg) == 0) + return (NULL); + + return (buf_ring_dequeue_sc(br)); +} + static __inline int drbr_empty(struct ifnet *ifp, struct buf_ring *br) { @@ -619,6 +640,16 @@ drbr_empty(struct ifnet *ifp, struct buf_ring *br) #endif return (buf_ring_empty(br)); } + +static __inline int +drbr_inuse(struct ifnet *ifp, struct buf_ring *br) +{ +#ifdef ALTQ + if (ALTQ_IS_ENABLED(&ifp->if_snd)) + return (ifp->if_snd.ifq_len); +#endif + return (buf_ring_count(br)); +} #endif /* * 72 was chosen below because it is the size of a TCP/IP |