From owner-svn-src-head@FreeBSD.ORG Fri Jul 27 05:34:46 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 63FB61065740; Fri, 27 Jul 2012 05:34:46 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 045B68FC15; Fri, 27 Jul 2012 05:34:46 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q6R5Yj3v069020; Fri, 27 Jul 2012 05:34:45 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q6R5Yj7J069017; Fri, 27 Jul 2012 05:34:45 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201207270534.q6R5Yj7J069017@svn.freebsd.org> From: Adrian Chadd Date: Fri, 27 Jul 2012 05:34:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r238822 - head/sys/dev/ath X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2012 05:34:46 -0000 Author: adrian Date: Fri Jul 27 05:34:45 2012 New Revision: 238822 URL: http://svn.freebsd.org/changeset/base/238822 Log: Refactor out the descriptor allocation code from the buffer allocation code. The TX EDMA completion path is going to need descriptors allocated but not any buffers. This code will form the basis for that. Modified: head/sys/dev/ath/if_ath.c head/sys/dev/ath/if_ath_misc.h Modified: head/sys/dev/ath/if_ath.c ============================================================================== --- head/sys/dev/ath/if_ath.c Fri Jul 27 05:33:55 2012 (r238821) +++ head/sys/dev/ath/if_ath.c Fri Jul 27 05:34:45 2012 (r238822) @@ -2764,8 +2764,14 @@ ath_load_cb(void *arg, bus_dma_segment_t *paddr = segs->ds_addr; } +/* + * Allocate the descriptors and appropriate DMA tag/setup. + * + * For some situations (eg EDMA TX completion), there isn't a requirement + * for the ath_buf entries to be allocated. + */ int -ath_descdma_setup(struct ath_softc *sc, +ath_descdma_alloc_desc(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, int ds_size, int nbuf, int ndesc) { @@ -2774,9 +2780,7 @@ ath_descdma_setup(struct ath_softc *sc, #define ATH_DESC_4KB_BOUND_CHECK(_daddr, _len) \ ((((u_int32_t)(_daddr) & 0xFFF) > (0x1000 - (_len))) ? 1 : 0) struct ifnet *ifp = sc->sc_ifp; - uint8_t *ds; - struct ath_buf *bf; - int i, bsize, error; + int error; dd->dd_descsize = ds_size; @@ -2844,10 +2848,49 @@ ath_descdma_setup(struct ath_softc *sc, goto fail2; } - ds = (uint8_t *) dd->dd_desc; DPRINTF(sc, ATH_DEBUG_RESET, "%s: %s DMA map: %p (%lu) -> %p (%lu)\n", - __func__, dd->dd_name, ds, (u_long) dd->dd_desc_len, - (caddr_t) dd->dd_desc_paddr, /*XXX*/ (u_long) dd->dd_desc_len); + __func__, dd->dd_name, (uint8_t *) dd->dd_desc, + (u_long) dd->dd_desc_len, (caddr_t) dd->dd_desc_paddr, + /*XXX*/ (u_long) dd->dd_desc_len); + + return (0); + +fail2: + bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); +fail1: + bus_dmamap_destroy(dd->dd_dmat, dd->dd_dmamap); +fail0: + bus_dma_tag_destroy(dd->dd_dmat); + memset(dd, 0, sizeof(*dd)); + return error; +#undef DS2PHYS +#undef ATH_DESC_4KB_BOUND_CHECK +} + +int +ath_descdma_setup(struct ath_softc *sc, + struct ath_descdma *dd, ath_bufhead *head, + const char *name, int ds_size, int nbuf, int ndesc) +{ +#define DS2PHYS(_dd, _ds) \ + ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc)) +#define ATH_DESC_4KB_BOUND_CHECK(_daddr, _len) \ + ((((u_int32_t)(_daddr) & 0xFFF) > (0x1000 - (_len))) ? 1 : 0) + struct ifnet *ifp = sc->sc_ifp; + uint8_t *ds; + struct ath_buf *bf; + int i, bsize, error; + + /* Allocate descriptors */ + error = ath_descdma_alloc_desc(sc, dd, head, name, ds_size, + nbuf, ndesc); + + /* Assume any errors during allocation were dealt with */ + if (error != 0) { + return (error); + } + + ds = (uint8_t *) dd->dd_desc; /* allocate rx buffers */ bsize = sizeof(struct ath_buf) * nbuf; @@ -2889,13 +2932,11 @@ ath_descdma_setup(struct ath_softc *sc, TAILQ_INSERT_TAIL(head, bf, bf_list); } return 0; + /* XXX this should likely just call ath_descdma_cleanup() */ fail3: bus_dmamap_unload(dd->dd_dmat, dd->dd_dmamap); -fail2: bus_dmamem_free(dd->dd_dmat, dd->dd_desc, dd->dd_dmamap); -fail1: bus_dmamap_destroy(dd->dd_dmat, dd->dd_dmamap); -fail0: bus_dma_tag_destroy(dd->dd_dmat); memset(dd, 0, sizeof(*dd)); return error; Modified: head/sys/dev/ath/if_ath_misc.h ============================================================================== --- head/sys/dev/ath/if_ath_misc.h Fri Jul 27 05:33:55 2012 (r238821) +++ head/sys/dev/ath/if_ath_misc.h Fri Jul 27 05:34:45 2012 (r238822) @@ -84,6 +84,9 @@ extern void ath_setdefantenna(struct ath extern void ath_setslottime(struct ath_softc *sc); +extern int ath_descdma_alloc_desc(struct ath_softc *sc, + struct ath_descdma *dd, ath_bufhead *head, const char *name, + int ds_size, int nbuf, int ndesc); extern int ath_descdma_setup(struct ath_softc *sc, struct ath_descdma *dd, ath_bufhead *head, const char *name, int ds_size, int nbuf, int ndesc);