From owner-svn-src-user@FreeBSD.ORG Fri Oct 18 13:05:19 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6272FBE; Fri, 18 Oct 2013 13:05:19 +0000 (UTC) (envelope-from andre@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4FFEA2F2C; Fri, 18 Oct 2013 13:05:19 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9ID5J6F055054; Fri, 18 Oct 2013 13:05:19 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9ID5JiS055053; Fri, 18 Oct 2013 13:05:19 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201310181305.r9ID5JiS055053@svn.freebsd.org> From: Andre Oppermann Date: Fri, 18 Oct 2013 13:05:19 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r256739 - user/andre/mbuf_staging/kern X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Oct 2013 13:05:19 -0000 Author: andre Date: Fri Oct 18 13:05:18 2013 New Revision: 256739 URL: http://svnweb.freebsd.org/changeset/base/256739 Log: Add/update/improve comments. Convert M_EXT test in m_clget() to KASSERT. Modified: user/andre/mbuf_staging/kern/kern_mbuf.c Modified: user/andre/mbuf_staging/kern/kern_mbuf.c ============================================================================== --- user/andre/mbuf_staging/kern/kern_mbuf.c Fri Oct 18 13:02:09 2013 (r256738) +++ user/andre/mbuf_staging/kern/kern_mbuf.c Fri Oct 18 13:05:18 2013 (r256739) @@ -297,7 +297,7 @@ static int mb_zinit_pack(void *, int, in static void mb_zfini_pack(void *, int); static void mb_reclaim(void *); -static void mb_free_ext(struct mbuf *) +static void mb_free_ext(struct mbuf *); static void *mbuf_jumbo_alloc(uma_zone_t, int, uint8_t *, int); /* @@ -310,15 +310,13 @@ struct mb_args { }; /* - * Initialize FreeBSD Network buffer allocation. + * Initialize FreeBSD network buffer allocation and + * configure UMA zones for mbufs, clusters, and packets. */ static void mbuf_init(void *dummy) { - /* - * Configure UMA zones for Mbufs, Clusters, and Packets. - */ zone_mbuf = uma_zcreate(MBUF_MEM_NAME, MSIZE, mb_ctor_mbuf, mb_dtor_mbuf, #ifdef INVARIANTS @@ -660,6 +658,9 @@ mb_ctor_pack(void *mem, int size, void * return (error); } +/* + * Find the UMA zone based on the size of an cluster allocation. + */ static uma_zone_t m_getzone(int size) { @@ -689,14 +690,9 @@ m_getzone(int size) /* * Initialize an mbuf with linear storage. - * - * Inline because the consumer text overhead will be roughly the same to - * initialize or call a function with this many parameters and M_PKTHDR - * should go away with constant propagation for !MGETHDR. */ int -m_init(struct mbuf *m, int size, int how, short type, - int flags) +m_init(struct mbuf *m, int size, int how, short type, int flags) { int error; @@ -714,6 +710,9 @@ m_init(struct mbuf *m, int size, int how return (0); } +/* + * Initialize the mh_pkthdr of an mbuf. + */ int m_pkthdr_init(struct mbuf *m, int how) { @@ -745,6 +744,9 @@ m_pkthdr_init(struct mbuf *m, int how) return (0); } +/* + * Allocate a stand-alone mbuf. + */ struct mbuf * m_get(int how, short type) { @@ -756,7 +758,8 @@ m_get(int how, short type) } /* - * XXX This should be deprecated, very little use. + * Allocate a stand-alone mbuf with the data field zeroed. + * XXX: This should be deprecated, very little use. */ struct mbuf * m_getclr(int how, short type) @@ -772,6 +775,9 @@ m_getclr(int how, short type) return (m); } +/* + * Allocate a stand-alone packet header mbuf. + */ struct mbuf * m_gethdr(int how, short type) { @@ -782,6 +788,9 @@ m_gethdr(int how, short type) return (uma_zalloc_arg(zone_mbuf, &args, how)); } +/* + * Allocate an mbuf+cluster package. + */ struct mbuf * m_getcl(int how, short type, int flags) { @@ -822,12 +831,16 @@ m_getjcl(int how, short type, int flags, return (m); } +/* + * Allocate a 2K cluster and attach it to an mbuf. + */ void m_clget(struct mbuf *m, int how) { - if (m->m_flags & M_EXT) - printf("%s: %p mbuf already has cluster\n", __func__, m); + KASSERT((m->m_flags & M_EXT) == 0, + ("%s: %p mbuf already has cluster", __func__, m)); + m->m_ext.ext_buf = (char *)NULL; uma_zalloc_arg(zone_clust, m, how); /* @@ -861,6 +874,9 @@ m_cljget(struct mbuf *m, int how, int si return (uma_zalloc_arg(zone, m, how)); } +/* + * Attach a previously allocated cluster to an mbuf. + */ void m_cljset(struct mbuf *m, void *cl, int type) { @@ -902,7 +918,9 @@ m_cljset(struct mbuf *m, void *cl, int t } /* - * m_get2() allocates minimum mbuf that would fit "size" argument. + * m_get2() allocates the smallest single mbuf, with external storage if + * necessray, that fits "size" argument. Returns NULL if the requested + * size exceeds the largest available size. */ struct mbuf * m_get2(int size, int how, short type, int flags) @@ -999,6 +1017,9 @@ m_getm2(struct mbuf *m, int len, int how return (m); } +/* + * Change the type of an mbuf. + */ void m_chtype(struct mbuf *m, short new_type) { @@ -1006,6 +1027,10 @@ m_chtype(struct mbuf *m, short new_type) m->m_type = new_type; } +/* + * Free a single mbuf or an entire chain of mbufs and associated external + * buffers, if applicable. + */ struct mbuf * m_free(struct mbuf *m) { @@ -1020,10 +1045,6 @@ m_free(struct mbuf *m) return (n); } -/* - * Free an entire chain of mbufs and associated external buffers, if - * applicable. - */ void m_freem(struct mbuf *mb) {