Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 Aug 2013 16:57:44 +0000 (UTC)
From:      Andre Oppermann <andre@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r254799 - in head/sys: dev/cas dev/hatm dev/iscsi_initiator dev/lge dev/mwl kern sys
Message-ID:  <201308241657.r7OGvie8033186@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andre
Date: Sat Aug 24 16:57:44 2013
New Revision: 254799
URL: http://svnweb.freebsd.org/changeset/base/254799

Log:
  Add an mbuf pointer parameter to (*ext_free) to give the external
  free function access to the mbuf the external memory was attached
  to.
  
  Mechanically adjust all users to include the mbuf parameter.
  
  This fixes a long standing annoyance for external free functions.
  Before one had to sacrifice one of the argument pointers for this.
  
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/sys/dev/cas/if_cas.c
  head/sys/dev/hatm/if_hatm_intr.c
  head/sys/dev/iscsi_initiator/isc_soc.c
  head/sys/dev/lge/if_lge.c
  head/sys/dev/mwl/if_mwl.c
  head/sys/kern/subr_mbpool.c
  head/sys/kern/uipc_mbuf.c
  head/sys/kern/uipc_syscalls.c
  head/sys/sys/mbpool.h
  head/sys/sys/mbuf.h
  head/sys/sys/sf_buf.h

Modified: head/sys/dev/cas/if_cas.c
==============================================================================
--- head/sys/dev/cas/if_cas.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/dev/cas/if_cas.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -132,7 +132,7 @@ static void	cas_detach(struct cas_softc 
 static int	cas_disable_rx(struct cas_softc *sc);
 static int	cas_disable_tx(struct cas_softc *sc);
 static void	cas_eint(struct cas_softc *sc, u_int status);
-static void	cas_free(void *arg1, void* arg2);
+static void	cas_free(struct mbuf *m, void *arg1, void* arg2);
 static void	cas_init(void *xsc);
 static void	cas_init_locked(struct cas_softc *sc);
 static void	cas_init_regs(struct cas_softc *sc);
@@ -1888,7 +1888,7 @@ cas_rint(struct cas_softc *sc)
 }
 
 static void
-cas_free(void *arg1, void *arg2)
+cas_free(struct mbuf *m, void *arg1, void *arg2)
 {
 	struct cas_rxdsoft *rxds;
 	struct cas_softc *sc;

Modified: head/sys/dev/hatm/if_hatm_intr.c
==============================================================================
--- head/sys/dev/hatm/if_hatm_intr.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/dev/hatm/if_hatm_intr.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -261,7 +261,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *
  * Free an mbuf and put it onto the free list.
  */
 static void
-hatm_mbuf0_free(void *buf, void *args)
+hatm_mbuf0_free(struct mbuf *m, void *buf, void *args)
 {
 	struct hatm_softc *sc = args;
 	struct mbuf0_chunk *c = buf;
@@ -272,7 +272,7 @@ hatm_mbuf0_free(void *buf, void *args)
 	hatm_ext_free(&sc->mbuf_list[0], (struct mbufx_free *)c);
 }
 static void
-hatm_mbuf1_free(void *buf, void *args)
+hatm_mbuf1_free(struct mbuf *m, void *buf, void *args)
 {
 	struct hatm_softc *sc = args;
 	struct mbuf1_chunk *c = buf;
@@ -461,7 +461,7 @@ hatm_rx_buffer(struct hatm_softc *sc, u_
 			    hatm_mbuf0_free, c0, sc, M_PKTHDR, EXT_EXTREF);
 			m->m_data += MBUF0_OFFSET;
 		} else
-			hatm_mbuf0_free(c0, sc);
+			hatm_mbuf0_free(NULL, c0, sc);
 
 	} else {
 		struct mbuf1_chunk *c1;
@@ -485,7 +485,7 @@ hatm_rx_buffer(struct hatm_softc *sc, u_
 			    hatm_mbuf1_free, c1, sc, M_PKTHDR, EXT_EXTREF);
 			m->m_data += MBUF1_OFFSET;
 		} else
-			hatm_mbuf1_free(c1, sc);
+			hatm_mbuf1_free(NULL, c1, sc);
 	}
 
 	return (m);

Modified: head/sys/dev/iscsi_initiator/isc_soc.c
==============================================================================
--- head/sys/dev/iscsi_initiator/isc_soc.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/dev/iscsi_initiator/isc_soc.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -69,7 +69,7 @@ static int ou_refcnt = 0;
  | function for freeing external storage for mbuf
  */
 static void
-ext_free(void *a, void *b)
+ext_free(struct mbuf *m, void *a, void *b)
 {
      pduq_t *pq = b;
 

Modified: head/sys/dev/lge/if_lge.c
==============================================================================
--- head/sys/dev/lge/if_lge.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/dev/lge/if_lge.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -122,7 +122,7 @@ static int lge_detach(device_t);
 static int lge_alloc_jumbo_mem(struct lge_softc *);
 static void lge_free_jumbo_mem(struct lge_softc *);
 static void *lge_jalloc(struct lge_softc *);
-static void lge_jfree(void *, void *);
+static void lge_jfree(struct mbuf *, void *, void *);
 
 static int lge_newbuf(struct lge_softc *, struct lge_rx_desc *, struct mbuf *);
 static int lge_encap(struct lge_softc *, struct mbuf *, u_int32_t *);
@@ -847,9 +847,7 @@ lge_jalloc(sc)
  * Release a jumbo buffer.
  */
 static void
-lge_jfree(buf, args)
-	void			*buf;
-	void			*args;
+lge_jfree(struct mbuf *m, void *buf, void *args)
 {
 	struct lge_softc	*sc;
 	int		        i;

Modified: head/sys/dev/mwl/if_mwl.c
==============================================================================
--- head/sys/dev/mwl/if_mwl.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/dev/mwl/if_mwl.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -2622,7 +2622,7 @@ mwl_rxbuf_init(struct mwl_softc *sc, str
 }
 
 static void
-mwl_ext_free(void *data, void *arg)
+mwl_ext_free(struct mbuf *m, void *data, void *arg)
 {
 	struct mwl_softc *sc = arg;
 

Modified: head/sys/kern/subr_mbpool.c
==============================================================================
--- head/sys/kern/subr_mbpool.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/kern/subr_mbpool.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -283,7 +283,7 @@ mbp_free(struct mbpool *p, void *ptr)
  * Mbuf system external mbuf free routine
  */
 void
-mbp_ext_free(void *buf, void *arg)
+mbp_ext_free(struct mbuf *m, void *buf, void *arg)
 {
 	mbp_free(arg, buf);
 }

Modified: head/sys/kern/uipc_mbuf.c
==============================================================================
--- head/sys/kern/uipc_mbuf.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/kern/uipc_mbuf.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -247,8 +247,8 @@ m_freem(struct mbuf *mb)
  */
 int
 m_extadd(struct mbuf *mb, caddr_t buf, u_int size,
-    void (*freef)(void *, void *), void *arg1, void *arg2, int flags, int type,
-    int wait)
+    void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2,
+    int flags, int type, int wait)
 {
 	KASSERT(type != EXT_CLUSTER, ("%s: EXT_CLUSTER not allowed", __func__));
 
@@ -321,7 +321,7 @@ mb_free_ext(struct mbuf *m)
 		case EXT_EXTREF:
 			KASSERT(m->m_ext.ext_free != NULL,
 				("%s: ext_free not set", __func__));
-			(*(m->m_ext.ext_free))(m->m_ext.ext_arg1,
+			(*(m->m_ext.ext_free))(m, m->m_ext.ext_arg1,
 			    m->m_ext.ext_arg2);
 			break;
 		default:

Modified: head/sys/kern/uipc_syscalls.c
==============================================================================
--- head/sys/kern/uipc_syscalls.c	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/kern/uipc_syscalls.c	Sat Aug 24 16:57:44 2013	(r254799)
@@ -1855,7 +1855,7 @@ struct sendfile_sync {
  * Detach mapped page and release resources back to the system.
  */
 void
-sf_buf_mext(void *addr, void *args)
+sf_buf_mext(struct mbuf *mb, void *addr, void *args)
 {
 	vm_page_t m;
 	struct sendfile_sync *sfs;
@@ -2315,14 +2315,14 @@ retry_space:
 			m0 = m_get((mnw ? M_NOWAIT : M_WAITOK), MT_DATA);
 			if (m0 == NULL) {
 				error = (mnw ? EAGAIN : ENOBUFS);
-				sf_buf_mext(NULL, sf);
+				sf_buf_mext(NULL, NULL, sf);
 				break;
 			}
 			if (m_extadd(m0, (caddr_t )sf_buf_kva(sf), PAGE_SIZE,
 			    sf_buf_mext, sfs, sf, M_RDONLY, EXT_SFBUF,
 			    (mnw ? M_NOWAIT : M_WAITOK)) != 0) {
 				error = (mnw ? EAGAIN : ENOBUFS);
-				sf_buf_mext(NULL, sf);
+				sf_buf_mext(NULL, NULL, sf);
 				m_freem(m0);
 				break;
 			}

Modified: head/sys/sys/mbpool.h
==============================================================================
--- head/sys/sys/mbpool.h	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/sys/mbpool.h	Sat Aug 24 16:57:44 2013	(r254799)
@@ -69,7 +69,7 @@ void *mbp_alloc(struct mbpool *, bus_add
 void mbp_free(struct mbpool *, void *);
 
 /* free a chunk that is an external mbuf */
-void mbp_ext_free(void *, void *);
+void mbp_ext_free(struct mbuf *, void *, void *);
 
 /* free all buffers that are marked to be on the card */
 void mbp_card_free(struct mbpool *);

Modified: head/sys/sys/mbuf.h
==============================================================================
--- head/sys/sys/mbuf.h	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/sys/mbuf.h	Sat Aug 24 16:57:44 2013	(r254799)
@@ -148,7 +148,7 @@ struct m_ext {
 	uint32_t	 ext_type:8,	/* type of external storage */
 			 ext_flags:24;	/* external storage mbuf flags */
 	void		(*ext_free)	/* free routine if not the usual */
-			    (void *, void *);
+			    (struct mbuf *, void *, void *);
 	void		*ext_arg1;	/* optional argument pointer */
 	void		*ext_arg2;	/* optional argument pointer */
 };
@@ -822,7 +822,8 @@ int		 m_apply(struct mbuf *, int, int,
 int		 m_append(struct mbuf *, int, c_caddr_t);
 void		 m_cat(struct mbuf *, struct mbuf *);
 int		 m_extadd(struct mbuf *, caddr_t, u_int,
-		    void (*)(void *, void *), void *, void *, int, int, int);
+		    void (*)(struct mbuf *, void *, void *), void *, void *,
+		    int, int, int);
 struct mbuf	*m_collapse(struct mbuf *, int, int);
 void		 m_copyback(struct mbuf *, int, int, c_caddr_t);
 void		 m_copydata(const struct mbuf *, int, int, caddr_t);

Modified: head/sys/sys/sf_buf.h
==============================================================================
--- head/sys/sys/sf_buf.h	Sat Aug 24 16:55:53 2013	(r254798)
+++ head/sys/sys/sf_buf.h	Sat Aug 24 16:57:44 2013	(r254799)
@@ -55,6 +55,7 @@ struct sfstat {				/* sendfile statistic
 #ifdef _KERNEL
 #include <machine/sf_buf.h>
 #include <sys/counter.h>
+struct mbuf;	/* for sf_buf_mext() */
 
 extern counter_u64_t sfstat[sizeof(struct sfstat) / sizeof(uint64_t)];
 #define	SFSTAT_ADD(name, val)	\
@@ -66,6 +67,6 @@ extern counter_u64_t sfstat[sizeof(struc
 struct sf_buf *
 	sf_buf_alloc(struct vm_page *m, int flags);
 void	sf_buf_free(struct sf_buf *sf);
-void	sf_buf_mext(void *addr, void *args);
+void	sf_buf_mext(struct mbuf *mb, void *addr, void *args);
 
 #endif /* !_SYS_SF_BUF_H_ */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308241657.r7OGvie8033186>