From owner-svn-src-head@FreeBSD.ORG Wed Dec 17 04:00:43 2008 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73D0D106571D; Wed, 17 Dec 2008 04:00:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 62D038FC20; Wed, 17 Dec 2008 04:00:43 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id mBH40hem056847; Wed, 17 Dec 2008 04:00:43 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id mBH40hTr056845; Wed, 17 Dec 2008 04:00:43 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200812170400.mBH40hTr056845@svn.freebsd.org> From: Kip Macy Date: Wed, 17 Dec 2008 04:00:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r186207 - in head/sys: net sys X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Dec 2008 04:00:43 -0000 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 #include +#include #endif /* _KERNEL */ #include /* XXX */ #include /* 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;