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
This commit is contained in:
Andre Oppermann 2013-08-24 16:57:44 +00:00
parent 06b77ec36d
commit 9a73687609
11 changed files with 23 additions and 23 deletions

View File

@ -132,7 +132,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(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;

View File

@ -261,7 +261,7 @@ hatm_mbuf_page_alloc(struct hatm_softc *sc, u_int group)
* 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_int group, u_int handle)
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_int group, u_int handle)
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);

View File

@ -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;

View File

@ -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;

View File

@ -2622,7 +2622,7 @@ mwl_rxbuf_init(struct mwl_softc *sc, struct mwl_rxbuf *bf)
}
static void
mwl_ext_free(void *data, void *arg)
mwl_ext_free(struct mbuf *m, void *data, void *arg)
{
struct mwl_softc *sc = arg;

View File

@ -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);
}

View File

@ -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:

View File

@ -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 @@ vn_sendfile(struct file *fp, int sockfd, struct uio *hdr_uio,
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;
}

View File

@ -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(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 *);

View File

@ -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);

View File

@ -55,6 +55,7 @@ struct sfstat { /* sendfile statistics */
#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(struct sfstat) / sizeof(uint64_t)];
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_ */