From owner-svn-src-all@FreeBSD.ORG Sun Aug 25 10:57:13 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 2A0C8FD3; Sun, 25 Aug 2013 10:57:13 +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 15CD12726; Sun, 25 Aug 2013 10:57:13 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7PAvD6K018933; Sun, 25 Aug 2013 10:57:13 GMT (envelope-from andre@svn.freebsd.org) Received: (from andre@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7PAv9Pt018914; Sun, 25 Aug 2013 10:57:09 GMT (envelope-from andre@svn.freebsd.org) Message-Id: <201308251057.r7PAv9Pt018914@svn.freebsd.org> From: Andre Oppermann Date: Sun, 25 Aug 2013 10:57:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254842 - in head/sys: compat/ndis dev/cas dev/hatm dev/if_ndis dev/iscsi_initiator dev/lge dev/mwl dev/wb kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2013 10:57:13 -0000 Author: andre Date: Sun Aug 25 10:57:09 2013 New Revision: 254842 URL: http://svnweb.freebsd.org/changeset/base/254842 Log: Give (*ext_free) an int return value allowing for very sophisticated external mbuf buffer management capabilities in the future. For now only EXT_FREE_OK is defined with current legacy behavior. Sponsored by: The FreeBSD Foundation Modified: head/sys/compat/ndis/kern_ndis.c head/sys/compat/ndis/ndis_var.h head/sys/dev/cas/if_cas.c head/sys/dev/hatm/if_hatm_intr.c head/sys/dev/if_ndis/if_ndis.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/dev/wb/if_wb.c head/sys/kern/subr_mbpool.c head/sys/kern/uipc_cow.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/compat/ndis/kern_ndis.c ============================================================================== --- head/sys/compat/ndis/kern_ndis.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/compat/ndis/kern_ndis.c Sun Aug 25 10:57:09 2013 (r254842) @@ -482,16 +482,14 @@ ndis_return(dobj, arg) KeReleaseSpinLock(&block->nmb_returnlock, irql); } -void -ndis_return_packet(buf, arg) - void *buf; /* not used */ - void *arg; +int +ndis_return_packet(struct mbuf *m, void *buf, void *arg) { ndis_packet *p; ndis_miniport_block *block; if (arg == NULL) - return; + return (EXT_FREE_OK); p = arg; @@ -500,7 +498,7 @@ ndis_return_packet(buf, arg) /* Release packet when refcount hits zero, otherwise return. */ if (p->np_refcnt) - return; + return (EXT_FREE_OK); block = ((struct ndis_softc *)p->np_softc)->ndis_block; @@ -512,6 +510,8 @@ ndis_return_packet(buf, arg) IoQueueWorkItem(block->nmb_returnitem, (io_workitem_func)kernndis_functbl[7].ipt_wrap, WORKQUEUE_CRITICAL, block); + + return (EXT_FREE_OK); } void Modified: head/sys/compat/ndis/ndis_var.h ============================================================================== --- head/sys/compat/ndis/ndis_var.h Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/compat/ndis/ndis_var.h Sun Aug 25 10:57:09 2013 (r254842) @@ -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(void *, void *); +extern int ndis_return_packet(struct mbuf *, void *, void *); extern int ndis_init_dma(void *); extern int ndis_destroy_dma(void *); extern int ndis_create_sysctls(void *); Modified: head/sys/dev/cas/if_cas.c ============================================================================== --- head/sys/dev/cas/if_cas.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/dev/cas/if_cas.c Sun Aug 25 10:57:09 2013 (r254842) @@ -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(struct mbuf *m, void *arg1, void* arg2); +static int 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); @@ -1887,7 +1887,7 @@ cas_rint(struct cas_softc *sc) #endif } -static void +static int cas_free(struct mbuf *m, void *arg1, void *arg2) { struct cas_rxdsoft *rxds; @@ -1904,7 +1904,7 @@ cas_free(struct mbuf *m, void *arg1, voi rxds = &sc->sc_rxdsoft[idx]; #endif if (refcount_release(&rxds->rxds_refcount) == 0) - return; + return (EXT_FREE_OK); /* * NB: this function can be called via m_freem(9) within @@ -1915,6 +1915,7 @@ cas_free(struct mbuf *m, void *arg1, voi cas_add_rxdesc(sc, idx); if (locked == 0) CAS_UNLOCK(sc); + return (EXT_FREE_OK); } static inline void Modified: head/sys/dev/hatm/if_hatm_intr.c ============================================================================== --- head/sys/dev/hatm/if_hatm_intr.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/dev/hatm/if_hatm_intr.c Sun Aug 25 10:57:09 2013 (r254842) @@ -260,7 +260,7 @@ hatm_mbuf_page_alloc(struct hatm_softc * /* * Free an mbuf and put it onto the free list. */ -static void +static int hatm_mbuf0_free(struct mbuf *m, void *buf, void *args) { struct hatm_softc *sc = args; @@ -270,8 +270,9 @@ hatm_mbuf0_free(struct mbuf *m, void *bu ("freeing unused mbuf %x", c->hdr.flags)); c->hdr.flags &= ~MBUF_USED; hatm_ext_free(&sc->mbuf_list[0], (struct mbufx_free *)c); + return (EXT_FREE_OK); } -static void +static int hatm_mbuf1_free(struct mbuf *m, void *buf, void *args) { struct hatm_softc *sc = args; @@ -281,6 +282,7 @@ hatm_mbuf1_free(struct mbuf *m, void *bu ("freeing unused mbuf %x", c->hdr.flags)); c->hdr.flags &= ~MBUF_USED; hatm_ext_free(&sc->mbuf_list[1], (struct mbufx_free *)c); + return (EXT_FREE_OK); } static void @@ -461,7 +463,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(NULL, c0, sc); + (void)hatm_mbuf0_free(NULL, c0, sc); } else { struct mbuf1_chunk *c1; @@ -485,7 +487,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(NULL, c1, sc); + (void)hatm_mbuf1_free(NULL, c1, sc); } return (m); Modified: head/sys/dev/if_ndis/if_ndis.c ============================================================================== --- head/sys/dev/if_ndis/if_ndis.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/dev/if_ndis/if_ndis.c Sun Aug 25 10:57:09 2013 (r254842) @@ -1401,7 +1401,7 @@ ndis_rxeof(adapter, packets, pktcnt) p = packets[i]; if (p->np_oob.npo_status == NDIS_STATUS_SUCCESS) { p->np_refcnt++; - ndis_return_packet(p, block); + (void)ndis_return_packet(NULL ,p, block); } } return; @@ -1414,7 +1414,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) - ndis_return_packet(p, block); + (void)ndis_return_packet(NULL, p, block); } else { #ifdef notdef if (p->np_oob.npo_status == NDIS_STATUS_RESOURCES) { Modified: head/sys/dev/iscsi_initiator/isc_soc.c ============================================================================== --- head/sys/dev/iscsi_initiator/isc_soc.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/dev/iscsi_initiator/isc_soc.c Sun Aug 25 10:57:09 2013 (r254842) @@ -68,7 +68,7 @@ static int ou_refcnt = 0; /* | function for freeing external storage for mbuf */ -static void +static int ext_free(struct mbuf *m, void *a, void *b) { pduq_t *pq = b; @@ -78,6 +78,7 @@ ext_free(struct mbuf *m, void *a, void * free(pq->buf, M_ISCSIBUF); pq->buf = NULL; } + return (EXT_FREE_OK); } int Modified: head/sys/dev/lge/if_lge.c ============================================================================== --- head/sys/dev/lge/if_lge.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/dev/lge/if_lge.c Sun Aug 25 10:57:09 2013 (r254842) @@ -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(struct mbuf *, void *, void *); +static int 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 *); @@ -846,7 +846,7 @@ lge_jalloc(sc) /* * Release a jumbo buffer. */ -static void +static int lge_jfree(struct mbuf *m, void *buf, void *args) { struct lge_softc *sc; @@ -873,7 +873,7 @@ lge_jfree(struct mbuf *m, void *buf, voi SLIST_REMOVE_HEAD(&sc->lge_jinuse_listhead, jpool_entries); SLIST_INSERT_HEAD(&sc->lge_jfree_listhead, entry, jpool_entries); - return; + return (EXT_FREE_OK); } /* Modified: head/sys/dev/mwl/if_mwl.c ============================================================================== --- head/sys/dev/mwl/if_mwl.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/dev/mwl/if_mwl.c Sun Aug 25 10:57:09 2013 (r254842) @@ -2621,7 +2621,7 @@ mwl_rxbuf_init(struct mwl_softc *sc, str return 0; } -static void +static int mwl_ext_free(struct mbuf *m, void *data, void *arg) { struct mwl_softc *sc = arg; @@ -2637,6 +2637,7 @@ mwl_ext_free(struct mbuf *m, void *data, sc->sc_rxblocked = 0; mwl_hal_intrset(sc->sc_mh, sc->sc_imask); } + return (EXT_FREE_OK); } struct mwl_frame_bar { Modified: head/sys/dev/wb/if_wb.c ============================================================================== --- head/sys/dev/wb/if_wb.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/dev/wb/if_wb.c Sun Aug 25 10:57:09 2013 (r254842) @@ -142,7 +142,7 @@ static int wb_probe(device_t); static int wb_attach(device_t); static int wb_detach(device_t); -static void wb_bfree(void *addr, void *args); +static int wb_bfree(struct mbuf *, void *addr, void *args); 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 *); @@ -822,12 +822,11 @@ wb_list_rx_init(sc) return(0); } -static void -wb_bfree(buf, args) - void *buf; - void *args; +static int +wb_bfree(struct mbuf *m, void *buf, void *args) { + return (EXT_FREE_OK); } /* Modified: head/sys/kern/subr_mbpool.c ============================================================================== --- head/sys/kern/subr_mbpool.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/kern/subr_mbpool.c Sun Aug 25 10:57:09 2013 (r254842) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include MODULE_VERSION(libmbpool, 1); @@ -282,10 +283,12 @@ mbp_free(struct mbpool *p, void *ptr) /* * Mbuf system external mbuf free routine */ -void +int mbp_ext_free(struct mbuf *m, void *buf, void *arg) { mbp_free(arg, buf); + + return (EXT_FREE_OK); } /* Modified: head/sys/kern/uipc_cow.c ============================================================================== --- head/sys/kern/uipc_cow.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/kern/uipc_cow.c Sun Aug 25 10:57:09 2013 (r254842) @@ -70,9 +70,9 @@ struct netsend_cow_stats { static struct netsend_cow_stats socow_stats; -static void socow_iodone(struct mbuf *m, void *addr, void *args); +static int socow_iodone(struct mbuf *m, void *addr, void *args); -static void +static int socow_iodone(struct mbuf *m, void *addr, void *args) { struct sf_buf *sf; @@ -94,6 +94,7 @@ socow_iodone(struct mbuf *m, void *addr, vm_page_free(pp); vm_page_unlock(pp); socow_stats.iodone++; + return (EXT_FREE_OK); } int Modified: head/sys/kern/uipc_mbuf.c ============================================================================== --- head/sys/kern/uipc_mbuf.c Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/kern/uipc_mbuf.c Sun Aug 25 10:57:09 2013 (r254842) @@ -247,7 +247,7 @@ m_freem(struct mbuf *mb) */ int m_extadd(struct mbuf *mb, caddr_t buf, u_int size, - void (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2, + int (*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->m_ext.ext_arg1, + (void)(*(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 Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/kern/uipc_syscalls.c Sun Aug 25 10:57:09 2013 (r254842) @@ -1854,7 +1854,7 @@ struct sendfile_sync { /* * Detach mapped page and release resources back to the system. */ -void +int sf_buf_mext(struct mbuf *mb, void *addr, void *args) { vm_page_t m; @@ -1873,13 +1873,14 @@ sf_buf_mext(struct mbuf *mb, void *addr, vm_page_free(m); vm_page_unlock(m); if (addr == NULL) - return; + return (EXT_FREE_OK); sfs = addr; mtx_lock(&sfs->mtx); KASSERT(sfs->count> 0, ("Sendfile sync botchup count == 0")); if (--sfs->count == 0) cv_signal(&sfs->cv); mtx_unlock(&sfs->mtx); + return (EXT_FREE_OK); } /* @@ -2315,14 +2316,14 @@ retry_space: m0 = m_get((mnw ? M_NOWAIT : M_WAITOK), MT_DATA); if (m0 == NULL) { error = (mnw ? EAGAIN : ENOBUFS); - sf_buf_mext(NULL, NULL, sf); + (void)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, NULL, sf); + (void)sf_buf_mext(NULL, NULL, sf); m_freem(m0); break; } Modified: head/sys/sys/mbpool.h ============================================================================== --- head/sys/sys/mbpool.h Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/sys/mbpool.h Sun Aug 25 10:57:09 2013 (r254842) @@ -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(struct mbuf *, void *, void *); +int 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 Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/sys/mbuf.h Sun Aug 25 10:57:09 2013 (r254842) @@ -165,7 +165,7 @@ struct m_ext { 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 */ + int (*ext_free) /* free routine if not the usual */ (struct mbuf *, void *, void *); void *ext_arg1; /* optional argument pointer */ void *ext_arg2; /* optional argument pointer */ @@ -366,6 +366,11 @@ struct mbuf { "\30EXT_FLAG_EXP4" /* + * Return values for (*ext_free). + */ +#define EXT_FREE_OK 0 /* Normal return */ + +/* * Flags indicating checksum, segmentation and other offload work to be * done, or already done, by hardware or lower layers. It is split into * separate inbound and outbound flags. @@ -895,7 +900,7 @@ 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 (*)(struct mbuf *, void *, void *), void *, void *, + int (*)(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); Modified: head/sys/sys/sf_buf.h ============================================================================== --- head/sys/sys/sf_buf.h Sun Aug 25 10:28:02 2013 (r254841) +++ head/sys/sys/sf_buf.h Sun Aug 25 10:57:09 2013 (r254842) @@ -67,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(struct mbuf *mb, void *addr, void *args); +int sf_buf_mext(struct mbuf *mb, void *addr, void *args); #endif /* !_SYS_SF_BUF_H_ */