Author: adrian
Date: Fri Jul 27 05:48:42 2012
New Revision: 238824
URL: http://svn.freebsd.org/changeset/base/238824

Log:
  Migrate the descriptor allocation function to not care about the number
  of buffers, only the number of descriptors.
  
  This involves:
  
  * Change the allocation function to not use nbuf at all;
  * When calling it, pass in "nbuf * ndesc" to correctly update how many
    descriptors are being allocated.
  
  Whilst here, fix the descriptor allocation code to correctly allocate
  a larger buffer size if the Merlin 4KB WAR is required.  It overallocates
  descriptors when allocating a block that doesn't ever have a 4KB boundary
  being crossed, but that can be fixed at a later stage.

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:37:01 2012        (r238823)
+++ head/sys/dev/ath/if_ath.c   Fri Jul 27 05:48:42 2012        (r238824)
@@ -2773,7 +2773,7 @@ ath_load_cb(void *arg, bus_dma_segment_t
 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)
+       const char *name, int ds_size, int ndesc)
 {
 #define        DS2PHYS(_dd, _ds) \
        ((_dd)->dd_desc_paddr + ((caddr_t)(_ds) - (caddr_t)(_dd)->dd_desc))
@@ -2785,11 +2785,11 @@ ath_descdma_alloc_desc(struct ath_softc 
        dd->dd_descsize = ds_size;
 
        DPRINTF(sc, ATH_DEBUG_RESET,
-           "%s: %s DMA: %u buffers %u desc/buf, %d bytes per descriptor\n",
-           __func__, name, nbuf, ndesc, dd->dd_descsize);
+           "%s: %s DMA: %u desc, %d bytes per descriptor\n",
+           __func__, name, ndesc, dd->dd_descsize);
 
        dd->dd_name = name;
-       dd->dd_desc_len = dd->dd_descsize * nbuf * ndesc;
+       dd->dd_desc_len = dd->dd_descsize * ndesc;
 
        /*
         * Merlin work-around:
@@ -2797,8 +2797,8 @@ ath_descdma_alloc_desc(struct ath_softc 
         * Assume one skipped descriptor per 4KB page.
         */
        if (! ath_hal_split4ktrans(sc->sc_ah)) {
-               int numdescpage = 4096 / (dd->dd_descsize * ndesc);
-               dd->dd_desc_len = (nbuf / numdescpage + 1) * 4096;
+               int numpages = dd->dd_desc_len / 4096;
+               dd->dd_desc_len += ds_size * numpages;
        }
 
        /*
@@ -2834,7 +2834,7 @@ ath_descdma_alloc_desc(struct ath_softc 
                                 &dd->dd_dmamap);
        if (error != 0) {
                if_printf(ifp, "unable to alloc memory for %u %s descriptors, "
-                       "error %u\n", nbuf * ndesc, dd->dd_name, error);
+                       "error %u\n", ndesc, dd->dd_name, error);
                goto fail1;
        }
 
@@ -2883,7 +2883,7 @@ ath_descdma_setup(struct ath_softc *sc,
 
        /* Allocate descriptors */
        error = ath_descdma_alloc_desc(sc, dd, head, name, ds_size,
-           nbuf, ndesc);
+           nbuf * ndesc);
 
        /* Assume any errors during allocation were dealt with */
        if (error != 0) {

Modified: head/sys/dev/ath/if_ath_misc.h
==============================================================================
--- head/sys/dev/ath/if_ath_misc.h      Fri Jul 27 05:37:01 2012        
(r238823)
+++ head/sys/dev/ath/if_ath_misc.h      Fri Jul 27 05:48:42 2012        
(r238824)
@@ -86,7 +86,7 @@ extern void ath_setslottime(struct ath_s
 
 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);
+           int ds_size, 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);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to