aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2017-10-09 20:35:31 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2017-10-09 20:35:31 +0000
commite8fd18f306915c411b08ab4664ec0aa3bc03d4d4 (patch)
tree889c5459ce4e793e93ed7c8618572e602b4bf058 /sys
parent32b413d7f0c47e033002e639b2049667b0891113 (diff)
downloadsrc-e8fd18f306915c411b08ab4664ec0aa3bc03d4d4.tar.gz
src-e8fd18f306915c411b08ab4664ec0aa3bc03d4d4.zip
Shorten list of arguments to mbuf external storage freeing function.
All of these arguments are stored in m_ext, so there is no reason to pass them in the argument list. Not all functions need the second argument, some don't even need the first one. The second argument lives in next cache line, so not dereferencing it is a performance gain. This was discovered in sendfile(2), which will be covered by next commits. The second goal of this commit is to bring even more flexibility to m_ext mbufs, allowing to create more fields in m_ext, opaque to the generic mbuf code, and potentially set and dereferenced by subsystems. Reviewed by: gallatin, kbowling Differential Revision: https://reviews.freebsd.org/D12615
Notes
Notes: svn path=/head/; revision=324446
Diffstat (limited to 'sys')
-rw-r--r--sys/compat/ndis/kern_ndis.c19
-rw-r--r--sys/compat/ndis/ndis_var.h2
-rw-r--r--sys/dev/cas/if_cas.c42
-rw-r--r--sys/dev/cas/if_casvar.h15
-rw-r--r--sys/dev/cxgbe/t4_sge.c6
-rw-r--r--sys/dev/cxgbe/tom/t4_cpl_io.c4
-rw-r--r--sys/dev/dpaa/if_dtsec_rm.c6
-rw-r--r--sys/dev/if_ndis/if_ndis.c4
-rw-r--r--sys/dev/iscsi_initiator/isc_soc.c14
-rw-r--r--sys/dev/lge/if_lge.c15
-rw-r--r--sys/dev/mwl/if_mwl.c10
-rw-r--r--sys/dev/netmap/netmap_generic.c4
-rw-r--r--sys/dev/wb/if_wb.c9
-rw-r--r--sys/kern/kern_mbuf.c13
-rw-r--r--sys/kern/subr_mbpool.c4
-rw-r--r--sys/sys/mbpool.h2
-rw-r--r--sys/sys/mbuf.h25
17 files changed, 75 insertions, 119 deletions
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index 55b22a22803e..fb9dcaaf7a8d 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -495,17 +495,21 @@ ndis_return(dobj, arg)
KeReleaseSpinLock(&block->nmb_returnlock, irql);
}
+static void
+ndis_ext_free(struct mbuf *m)
+{
+
+ return (ndis_return_packet(m->m_ext.ext_arg1));
+}
+
void
-ndis_return_packet(struct mbuf *m, void *buf, void *arg)
+ndis_return_packet(ndis_packet *p)
{
- ndis_packet *p;
ndis_miniport_block *block;
- if (arg == NULL)
+ if (p == NULL)
return;
- p = arg;
-
/* Decrement refcount. */
p->np_refcnt--;
@@ -676,9 +680,8 @@ ndis_ptom(m0, p)
return (ENOBUFS);
}
m->m_len = MmGetMdlByteCount(buf);
- m->m_data = MmGetMdlVirtualAddress(buf);
- MEXTADD(m, m->m_data, m->m_len, ndis_return_packet,
- m->m_data, p, 0, EXT_NDIS);
+ m_extadd(m, MmGetMdlVirtualAddress(buf), m->m_len,
+ ndis_ext_free, p, NULL, 0, EXT_NDIS);
p->np_refcnt++;
totlen += m->m_len;
diff --git a/sys/compat/ndis/ndis_var.h b/sys/compat/ndis/ndis_var.h
index 80b49207c25a..92e62a1fbdbc 100644
--- a/sys/compat/ndis/ndis_var.h
+++ b/sys/compat/ndis/ndis_var.h
@@ -1743,7 +1743,7 @@ extern int ndis_halt_nic(void *);
extern int ndis_shutdown_nic(void *);
extern int ndis_pnpevent_nic(void *, int);
extern int ndis_init_nic(void *);
-extern void ndis_return_packet(struct mbuf *, void *, void *);
+extern void ndis_return_packet(ndis_packet *);
extern int ndis_init_dma(void *);
extern int ndis_destroy_dma(void *);
extern int ndis_create_sysctls(void *);
diff --git a/sys/dev/cas/if_cas.c b/sys/dev/cas/if_cas.c
index 554b245260f5..8b5d9659063d 100644
--- a/sys/dev/cas/if_cas.c
+++ b/sys/dev/cas/if_cas.c
@@ -133,7 +133,7 @@ static void cas_detach(struct cas_softc *sc);
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(struct mbuf *m, void *arg1, void* arg2);
+static void cas_free(struct mbuf *m);
static void cas_init(void *xsc);
static void cas_init_locked(struct cas_softc *sc);
static void cas_init_regs(struct cas_softc *sc);
@@ -1732,16 +1732,10 @@ cas_rint(struct cas_softc *sc)
refcount_acquire(&rxds->rxds_refcount);
bus_dmamap_sync(sc->sc_rdmatag,
rxds->rxds_dmamap, BUS_DMASYNC_POSTREAD);
-#if __FreeBSD_version < 800016
- MEXTADD(m, (caddr_t)rxds->rxds_buf +
- off * 256 + ETHER_ALIGN, len, cas_free,
- rxds, M_RDONLY, EXT_NET_DRV);
-#else
- MEXTADD(m, (caddr_t)rxds->rxds_buf +
+ m_extadd(m, (char *)rxds->rxds_buf +
off * 256 + ETHER_ALIGN, len, cas_free,
sc, (void *)(uintptr_t)idx,
M_RDONLY, EXT_NET_DRV);
-#endif
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
m = NULL;
@@ -1779,16 +1773,10 @@ cas_rint(struct cas_softc *sc)
m->m_len = min(CAS_PAGE_SIZE - off, len);
bus_dmamap_sync(sc->sc_rdmatag,
rxds->rxds_dmamap, BUS_DMASYNC_POSTREAD);
-#if __FreeBSD_version < 800016
- MEXTADD(m, (caddr_t)rxds->rxds_buf + off,
- m->m_len, cas_free, rxds, M_RDONLY,
- EXT_NET_DRV);
-#else
- MEXTADD(m, (caddr_t)rxds->rxds_buf + off,
+ m_extadd(m, (char *)rxds->rxds_buf + off,
m->m_len, cas_free, sc,
(void *)(uintptr_t)idx, M_RDONLY,
EXT_NET_DRV);
-#endif
if ((m->m_flags & M_EXT) == 0) {
m_freem(m);
m = NULL;
@@ -1818,19 +1806,11 @@ cas_rint(struct cas_softc *sc)
sc->sc_rdmatag,
rxds2->rxds_dmamap,
BUS_DMASYNC_POSTREAD);
-#if __FreeBSD_version < 800016
- MEXTADD(m2,
- (caddr_t)rxds2->rxds_buf,
- m2->m_len, cas_free,
- rxds2, M_RDONLY,
- EXT_NET_DRV);
-#else
- MEXTADD(m2,
- (caddr_t)rxds2->rxds_buf,
+ m_extadd(m2,
+ (char *)rxds2->rxds_buf,
m2->m_len, cas_free, sc,
(void *)(uintptr_t)idx2,
M_RDONLY, EXT_NET_DRV);
-#endif
if ((m2->m_flags & M_EXT) ==
0) {
m_freem(m2);
@@ -1889,21 +1869,15 @@ cas_rint(struct cas_softc *sc)
}
static void
-cas_free(struct mbuf *m, void *arg1, void *arg2)
+cas_free(struct mbuf *m)
{
struct cas_rxdsoft *rxds;
struct cas_softc *sc;
u_int idx, locked;
-#if __FreeBSD_version < 800016
- rxds = arg2;
- sc = rxds->rxds_sc;
- idx = rxds->rxds_idx;
-#else
- sc = arg1;
- idx = (uintptr_t)arg2;
+ sc = m->m_ext.ext_arg1;
+ idx = (uintptr_t)m->m_ext.ext_arg2;
rxds = &sc->sc_rxdsoft[idx];
-#endif
if (refcount_release(&rxds->rxds_refcount) == 0)
return;
diff --git a/sys/dev/cas/if_casvar.h b/sys/dev/cas/if_casvar.h
index 653572c8b201..e92f277003e8 100644
--- a/sys/dev/cas/if_casvar.h
+++ b/sys/dev/cas/if_casvar.h
@@ -119,10 +119,6 @@ struct cas_rxdsoft {
void *rxds_buf; /* receive buffer */
bus_dmamap_t rxds_dmamap; /* our DMA map */
bus_addr_t rxds_paddr; /* physical address of the segment */
-#if __FreeBSD_version < 800016
- struct cas_softc *rxds_sc; /* softc pointer */
- u_int rxds_idx; /* our index */
-#endif
u_int rxds_refcount; /* hardware + mbuf references */
};
@@ -239,18 +235,7 @@ do { \
__CAS_UPDATE_RXDESC(&(sc)->sc_rxdescs[(d)], \
&(sc)->sc_rxdsoft[(s)], (s))
-#if __FreeBSD_version < 800016
-#define CAS_INIT_RXDESC(sc, d, s) \
-do { \
- struct cas_rxdsoft *__rxds = &(sc)->sc_rxdsoft[(s)]; \
- \
- __rxds->rxds_sc = (sc); \
- __rxds->rxds_idx = (s); \
- __CAS_UPDATE_RXDESC(&(sc)->sc_rxdescs[(d)], __rxds, (s)); \
-} while (0)
-#else
#define CAS_INIT_RXDESC(sc, d, s) CAS_UPDATE_RXDESC(sc, d, s)
-#endif
#define CAS_LOCK_INIT(_sc, _name) \
mtx_init(&(_sc)->sc_mtx, _name, MTX_NETWORK_LOCK, MTX_DEF)
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index c5860aee00da..c687afa80db3 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -1670,10 +1670,10 @@ cl_metadata(struct adapter *sc, struct sge_fl *fl, struct cluster_layout *cll,
}
static void
-rxb_free(struct mbuf *m, void *arg1, void *arg2)
+rxb_free(struct mbuf *m)
{
- uma_zone_t zone = arg1;
- caddr_t cl = arg2;
+ uma_zone_t zone = m->m_ext.ext_arg1;
+ void *cl = m->m_ext.ext_arg2;
uma_zfree(zone, cl);
counter_u64_add(extfree_rels, 1);
diff --git a/sys/dev/cxgbe/tom/t4_cpl_io.c b/sys/dev/cxgbe/tom/t4_cpl_io.c
index ba1fcbc7288c..0e40f6f6a80a 100644
--- a/sys/dev/cxgbe/tom/t4_cpl_io.c
+++ b/sys/dev/cxgbe/tom/t4_cpl_io.c
@@ -1979,9 +1979,9 @@ free_aiotx_buffer(struct aiotx_buffer *ab)
}
static void
-t4_aiotx_mbuf_free(struct mbuf *m, void *buffer, void *arg)
+t4_aiotx_mbuf_free(struct mbuf *m)
{
- struct aiotx_buffer *ab = buffer;
+ struct aiotx_buffer *ab = m->m_ext.ext_arg1;
#ifdef VERBOSE_TRACES
CTR3(KTR_CXGBE, "%s: completed %d bytes for tid %d", __func__,
diff --git a/sys/dev/dpaa/if_dtsec_rm.c b/sys/dev/dpaa/if_dtsec_rm.c
index 7939ae10648e..f2580d5f5a03 100644
--- a/sys/dev/dpaa/if_dtsec_rm.c
+++ b/sys/dev/dpaa/if_dtsec_rm.c
@@ -337,11 +337,13 @@ dtsec_rm_pool_rx_init(struct dtsec_softc *sc)
* @{
*/
static void
-dtsec_rm_fqr_mext_free(struct mbuf *m, void *buffer, void *arg)
+dtsec_rm_fqr_mext_free(struct mbuf *m)
{
struct dtsec_softc *sc;
+ void *buffer;
- sc = arg;
+ buffer = m->m_ext.ext_arg1;
+ sc = m->m_ext.ext_arg2;
if (bman_count(sc->sc_rx_pool) <= DTSEC_RM_POOL_RX_MAX_SIZE)
bman_put_buffer(sc->sc_rx_pool, buffer);
else
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index e35360c676d2..6083d9778c01 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -1418,7 +1418,7 @@ ndis_rxeof(adapter, packets, pktcnt)
p = packets[i];
if (p->np_oob.npo_status == NDIS_STATUS_SUCCESS) {
p->np_refcnt++;
- (void)ndis_return_packet(NULL ,p, block);
+ ndis_return_packet(p);
}
}
return;
@@ -1431,7 +1431,7 @@ ndis_rxeof(adapter, packets, pktcnt)
if (ndis_ptom(&m0, p)) {
device_printf(sc->ndis_dev, "ptom failed\n");
if (p->np_oob.npo_status == NDIS_STATUS_SUCCESS)
- (void)ndis_return_packet(NULL, p, block);
+ ndis_return_packet(p);
} else {
#ifdef notdef
if (p->np_oob.npo_status == NDIS_STATUS_RESOURCES) {
diff --git a/sys/dev/iscsi_initiator/isc_soc.c b/sys/dev/iscsi_initiator/isc_soc.c
index 1e25f7268360..ed84f192a6cf 100644
--- a/sys/dev/iscsi_initiator/isc_soc.c
+++ b/sys/dev/iscsi_initiator/isc_soc.c
@@ -70,12 +70,13 @@ static int ou_refcnt = 0;
| function for freeing external storage for mbuf
*/
static void
-ext_free(struct mbuf *m, void *a, void *b)
+ext_free(struct mbuf *m)
{
- pduq_t *pq = b;
+ pduq_t *pq = m->m_ext.ext_arg1;
if(pq->buf != NULL) {
- debug(3, "ou_refcnt=%d a=%p b=%p", ou_refcnt, a, pq->buf);
+ debug(3, "ou_refcnt=%d a=%p b=%p",
+ ou_refcnt, m->m_ext.ext_buf, pq->buf);
free(pq->buf, M_ISCSIBUF);
pq->buf = NULL;
}
@@ -137,11 +138,8 @@ isc_sendPDU(isc_session_t *sp, pduq_t *pq)
md->m_ext.ext_cnt = &ou_refcnt;
l = min(MCLBYTES, len);
debug(4, "setting ext_free(arg=%p len/l=%d/%d)", pq->buf, len, l);
- MEXTADD(md, pp->ds_addr + off, l, ext_free,
-#if __FreeBSD_version >= 800000
- pp->ds_addr + off,
-#endif
- pq, 0, EXT_EXTREF);
+ m_extadd(md, pp->ds_addr + off, l, ext_free, pq, NULL, 0,
+ EXT_EXTREF);
md->m_len = l;
md->m_next = NULL;
mh->m_pkthdr.len += l;
diff --git a/sys/dev/lge/if_lge.c b/sys/dev/lge/if_lge.c
index 262aab35522b..115d2fa74729 100644
--- a/sys/dev/lge/if_lge.c
+++ b/sys/dev/lge/if_lge.c
@@ -123,7 +123,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(struct mbuf *, void *, void *);
+static void lge_jfree(struct mbuf *);
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 *);
@@ -689,7 +689,7 @@ lge_newbuf(sc, c, m)
struct mbuf *m;
{
struct mbuf *m_new = NULL;
- caddr_t *buf = NULL;
+ char *buf = NULL;
if (m == NULL) {
MGETHDR(m_new, M_NOWAIT, MT_DATA);
@@ -710,10 +710,9 @@ lge_newbuf(sc, c, m)
return(ENOBUFS);
}
/* Attach the buffer to the mbuf */
- m_new->m_data = (void *)buf;
m_new->m_len = m_new->m_pkthdr.len = LGE_JUMBO_FRAMELEN;
- MEXTADD(m_new, buf, LGE_JUMBO_FRAMELEN, lge_jfree,
- buf, (struct lge_softc *)sc, 0, EXT_NET_DRV);
+ m_extadd(m_new, buf, LGE_JUMBO_FRAMELEN, lge_jfree, sc, NULL,
+ 0, EXT_NET_DRV);
} else {
m_new = m;
m_new->m_len = m_new->m_pkthdr.len = LGE_JUMBO_FRAMELEN;
@@ -848,20 +847,20 @@ lge_jalloc(sc)
* Release a jumbo buffer.
*/
static void
-lge_jfree(struct mbuf *m, void *buf, void *args)
+lge_jfree(struct mbuf *m)
{
struct lge_softc *sc;
int i;
struct lge_jpool_entry *entry;
/* Extract the softc struct pointer. */
- sc = args;
+ sc = m->m_ext.ext_arg1;
if (sc == NULL)
panic("lge_jfree: can't find softc pointer!");
/* calculate the slot this buffer belongs to */
- i = ((vm_offset_t)buf
+ i = ((vm_offset_t)m->m_ext.ext_buf
- (vm_offset_t)sc->lge_cdata.lge_jumbo_buf) / LGE_JLEN;
if ((i < 0) || (i >= LGE_JSLOTS))
diff --git a/sys/dev/mwl/if_mwl.c b/sys/dev/mwl/if_mwl.c
index 79172aaf7bd7..861cbff950f3 100644
--- a/sys/dev/mwl/if_mwl.c
+++ b/sys/dev/mwl/if_mwl.c
@@ -2522,12 +2522,12 @@ mwl_rxbuf_init(struct mwl_softc *sc, struct mwl_rxbuf *bf)
}
static void
-mwl_ext_free(struct mbuf *m, void *data, void *arg)
+mwl_ext_free(struct mbuf *m)
{
- struct mwl_softc *sc = arg;
+ struct mwl_softc *sc = m->m_ext.ext_arg1;
/* XXX bounds check data */
- mwl_putrxdma(sc, data);
+ mwl_putrxdma(sc, m->m_ext.ext_buf);
/*
* If we were previously blocked by a lack of rx dma buffers
* check if we now have enough to restart rx interrupt handling.
@@ -2746,8 +2746,8 @@ mwl_rx_proc(void *arg, int npending)
* descriptor using the replacement dma
* buffer we just installed above.
*/
- MEXTADD(m, data, MWL_AGGR_SIZE, mwl_ext_free,
- data, sc, 0, EXT_NET_DRV);
+ m_extadd(m, data, MWL_AGGR_SIZE, mwl_ext_free, sc, NULL, 0,
+ EXT_NET_DRV);
m->m_data += off - hdrlen;
m->m_pkthdr.len = m->m_len = pktlen;
/* NB: dma buffer assumed read-only */
diff --git a/sys/dev/netmap/netmap_generic.c b/sys/dev/netmap/netmap_generic.c
index 30f83a920825..939fed5b573b 100644
--- a/sys/dev/netmap/netmap_generic.c
+++ b/sys/dev/netmap/netmap_generic.c
@@ -166,7 +166,7 @@ nm_os_get_mbuf(struct ifnet *ifp, int len)
* has a KASSERT(), checking that the mbuf dtor function is not NULL.
*/
-static void void_mbuf_dtor(struct mbuf *m, void *arg1, void *arg2) { }
+static void void_mbuf_dtor(struct mbuf *m) { }
#define SET_MBUF_DESTRUCTOR(m, fn) do { \
(m)->m_ext.ext_free = (fn != NULL) ? \
@@ -624,7 +624,7 @@ generic_mbuf_destructor(struct mbuf *m)
* txsync. */
netmap_generic_irq(na, r, NULL);
#ifdef __FreeBSD__
- void_mbuf_dtor(m, NULL, NULL);
+ void_mbuf_dtor(m);
#endif
}
diff --git a/sys/dev/wb/if_wb.c b/sys/dev/wb/if_wb.c
index ca66226dd898..aa882f0d26c0 100644
--- a/sys/dev/wb/if_wb.c
+++ b/sys/dev/wb/if_wb.c
@@ -143,7 +143,7 @@ static int wb_probe(device_t);
static int wb_attach(device_t);
static int wb_detach(device_t);
-static void wb_bfree(struct mbuf *, void *addr, void *args);
+static void wb_bfree(struct mbuf *);
static int wb_newbuf(struct wb_softc *, struct wb_chain_onefrag *,
struct mbuf *);
static int wb_encap(struct wb_softc *, struct wb_chain *, struct mbuf *);
@@ -824,7 +824,7 @@ wb_list_rx_init(sc)
}
static void
-wb_bfree(struct mbuf *m, void *buf, void *args)
+wb_bfree(struct mbuf *m)
{
}
@@ -843,10 +843,9 @@ wb_newbuf(sc, c, m)
MGETHDR(m_new, M_NOWAIT, MT_DATA);
if (m_new == NULL)
return(ENOBUFS);
- m_new->m_data = c->wb_buf;
m_new->m_pkthdr.len = m_new->m_len = WB_BUFBYTES;
- MEXTADD(m_new, c->wb_buf, WB_BUFBYTES, wb_bfree, c->wb_buf,
- NULL, 0, EXT_NET_DRV);
+ m_extadd(m_new, c->wb_buf, WB_BUFBYTES, wb_bfree, NULL, NULL,
+ 0, EXT_NET_DRV);
} else {
m_new = m;
m_new->m_len = m_new->m_pkthdr.len = WB_BUFBYTES;
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c
index 0d0c1c86b168..815390ef8a49 100644
--- a/sys/kern/kern_mbuf.c
+++ b/sys/kern/kern_mbuf.c
@@ -504,7 +504,7 @@ mb_ctor_clust(void *mem, int size, void *arg, int how)
#endif
m = (struct mbuf *)arg;
if (m != NULL) {
- m->m_ext.ext_buf = (caddr_t)mem;
+ m->m_ext.ext_buf = (char *)mem;
m->m_data = m->m_ext.ext_buf;
m->m_flags |= M_EXT;
m->m_ext.ext_free = NULL;
@@ -688,15 +688,13 @@ mb_free_ext(struct mbuf *m)
case EXT_DISPOSABLE:
KASSERT(m->m_ext.ext_free != NULL,
("%s: ext_free not set", __func__));
- (*(m->m_ext.ext_free))(m, m->m_ext.ext_arg1,
- m->m_ext.ext_arg2);
+ m->m_ext.ext_free(m);
uma_zfree(zone_mbuf, mref);
break;
case EXT_EXTREF:
KASSERT(m->m_ext.ext_free != NULL,
("%s: ext_free not set", __func__));
- (*(m->m_ext.ext_free))(m, m->m_ext.ext_arg1,
- m->m_ext.ext_arg2);
+ m->m_ext.ext_free(m);
break;
default:
KASSERT(m->m_ext.ext_type == 0,
@@ -918,9 +916,8 @@ m_getm2(struct mbuf *m, int len, int how, short type, int flags)
* Nothing.
*/
void
-m_extadd(struct mbuf *mb, caddr_t buf, u_int size,
- void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2,
- int flags, int type)
+m_extadd(struct mbuf *mb, char *buf, u_int size, m_ext_free_t freef,
+ void *arg1, void *arg2, int flags, int type)
{
KASSERT(type != EXT_CLUSTER, ("%s: EXT_CLUSTER not allowed", __func__));
diff --git a/sys/kern/subr_mbpool.c b/sys/kern/subr_mbpool.c
index de79ad4d8c76..e1bae23ff2f1 100644
--- a/sys/kern/subr_mbpool.c
+++ b/sys/kern/subr_mbpool.c
@@ -281,10 +281,10 @@ mbp_free(struct mbpool *p, void *ptr)
* Mbuf system external mbuf free routine
*/
void
-mbp_ext_free(struct mbuf *m, void *buf, void *arg)
+mbp_ext_free(struct mbuf *m)
{
- mbp_free(arg, buf);
+ mbp_free(m->m_ext.ext_arg2, m->m_ext.ext_arg1);
}
/*
diff --git a/sys/sys/mbpool.h b/sys/sys/mbpool.h
index 48fd89eb99b5..be95d619827b 100644
--- a/sys/sys/mbpool.h
+++ b/sys/sys/mbpool.h
@@ -69,7 +69,7 @@ void *mbp_alloc(struct mbpool *, bus_addr_t *, uint32_t *);
void mbp_free(struct mbpool *, void *);
/* free a chunk that is an external mbuf */
-void mbp_ext_free(struct mbuf *, void *, void *);
+void mbp_ext_free(struct mbuf *);
/* free all buffers that are marked to be on the card */
void mbp_card_free(struct mbpool *);
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index daa3c0cba6e8..00d6adf3920d 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -197,17 +197,17 @@ struct pkthdr {
* Compile-time assertions in uipc_mbuf.c test these values to ensure that
* they are correct.
*/
+typedef void m_ext_free_t(struct mbuf *);
struct m_ext {
union {
volatile u_int ext_count; /* value of ref count info */
volatile u_int *ext_cnt; /* pointer to ref count info */
};
- caddr_t ext_buf; /* start of buffer */
+ char *ext_buf; /* start of buffer */
uint32_t ext_size; /* size of buffer, for ext_free */
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 */
- (struct mbuf *, void *, void *);
+ m_ext_free_t *ext_free; /* free routine if not the usual */
void *ext_arg1; /* optional argument pointer */
void *ext_arg2; /* optional argument pointer */
};
@@ -436,10 +436,10 @@ struct mbuf {
#define EXT_FLAG_NOFREE 0x000010 /* don't free mbuf to pool, notyet */
-#define EXT_FLAG_VENDOR1 0x010000 /* for vendor-internal use */
-#define EXT_FLAG_VENDOR2 0x020000 /* for vendor-internal use */
-#define EXT_FLAG_VENDOR3 0x040000 /* for vendor-internal use */
-#define EXT_FLAG_VENDOR4 0x080000 /* for vendor-internal use */
+#define EXT_FLAG_VENDOR1 0x010000 /* These flags are vendor */
+#define EXT_FLAG_VENDOR2 0x020000 /* or submodule specific, */
+#define EXT_FLAG_VENDOR3 0x040000 /* not used by mbuf code. */
+#define EXT_FLAG_VENDOR4 0x080000 /* Set/read by submodule. */
#define EXT_FLAG_EXP1 0x100000 /* for experimental use */
#define EXT_FLAG_EXP2 0x200000 /* for experimental use */
@@ -610,9 +610,8 @@ struct mbuf *m_devget(char *, int, int, struct ifnet *,
void (*)(char *, caddr_t, u_int));
struct mbuf *m_dup(const struct mbuf *, int);
int m_dup_pkthdr(struct mbuf *, const struct mbuf *, int);
-void m_extadd(struct mbuf *, caddr_t, u_int,
- void (*)(struct mbuf *, void *, void *), void *, void *,
- int, int);
+void m_extadd(struct mbuf *, char *, u_int, m_ext_free_t,
+ void *, void *, int, int);
u_int m_fixhdr(struct mbuf *);
struct mbuf *m_fragment(struct mbuf *, int, int);
void m_freem(struct mbuf *);
@@ -667,8 +666,8 @@ m_gettype(int size)
* Associated an external reference counted buffer with an mbuf.
*/
static __inline void
-m_extaddref(struct mbuf *m, caddr_t buf, u_int size, u_int *ref_cnt,
- void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2)
+m_extaddref(struct mbuf *m, char *buf, u_int size, u_int *ref_cnt,
+ m_ext_free_t freef, void *arg1, void *arg2)
{
KASSERT(ref_cnt != NULL, ("%s: ref_cnt not provided", __func__));
@@ -864,7 +863,7 @@ m_extrefcnt(struct mbuf *m)
#define MGETHDR(m, how, type) ((m) = m_gethdr((how), (type)))
#define MCLGET(m, how) m_clget((m), (how))
#define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \
- m_extadd((m), (caddr_t)(buf), (size), (free), (arg1), (arg2), \
+ m_extadd((m), (char *)(buf), (size), (free), (arg1), (arg2), \
(flags), (type))
#define m_getm(m, len, how, type) \
m_getm2((m), (len), (how), (type), M_PKTHDR)