svn commit: r186207 - in head/sys: net sys
Kip Macy
kmacy at FreeBSD.org
Wed Dec 17 04:00:43 UTC 2008
Author: kmacy
Date: Wed Dec 17 04:00:43 2008
New Revision: 186207
URL: http://svn.freebsd.org/changeset/base/186207
Log:
merge in 2 buf_ring helper routines for enqueueing and freeing buf_rings
Modified:
head/sys/net/if_var.h
head/sys/sys/buf_ring.h
Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h Wed Dec 17 03:57:28 2008 (r186206)
+++ head/sys/net/if_var.h Wed Dec 17 04:00:43 2008 (r186207)
@@ -77,6 +77,7 @@ struct ifvlantrunk;
#ifdef _KERNEL
#include <sys/mbuf.h>
#include <sys/eventhandler.h>
+#include <sys/buf_ring.h>
#endif /* _KERNEL */
#include <sys/lock.h> /* XXX */
#include <sys/mutex.h> /* XXX */
@@ -548,6 +549,32 @@ do { \
IFQ_PURGE(ifq); \
} while (0)
+#ifdef _KERNEL
+static __inline int
+drbr_enqueue(struct buf_ring *br, struct mbuf *m)
+{
+ int error = 0;
+
+ if ((error = buf_ring_enqueue(br, m)) == ENOBUFS) {
+ br->br_drops++;
+ m_freem(m);
+ }
+
+ return (error);
+}
+
+static __inline void
+drbr_free(struct buf_ring *br, struct malloc_type *type)
+{
+ struct mbuf *m;
+
+ while ((m = buf_ring_dequeue_sc(br)) != NULL)
+ m_freem(m);
+
+ buf_ring_free(br, type);
+}
+#endif
+
/*
* 72 was chosen below because it is the size of a TCP/IP
* header (40) + the minimum mss (32).
Modified: head/sys/sys/buf_ring.h
==============================================================================
--- head/sys/sys/buf_ring.h Wed Dec 17 03:57:28 2008 (r186206)
+++ head/sys/sys/buf_ring.h Wed Dec 17 04:00:43 2008 (r186207)
@@ -48,10 +48,11 @@ struct buf_ring {
volatile uint32_t br_prod_tail;
int br_prod_size;
int br_prod_mask;
+ uint64_t br_drops;
/*
* Pad out to next L2 cache line
*/
- uint64_t _pad0[14];
+ uint64_t _pad0[13];
volatile uint32_t br_cons_head;
volatile uint32_t br_cons_tail;
More information about the svn-src-head
mailing list