Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/alpha Add support for mbufs to the Alpha SGMAP DMA ...



details:   https://anonhg.NetBSD.org/src/rev/3531e25cf21d
branches:  trunk
changeset: 512913:3531e25cf21d
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jul 19 06:40:01 2001 +0000

description:
Add support for mbufs to the Alpha SGMAP DMA maps.

diffstat:

 sys/arch/alpha/common/sgmap_typedep.c |  120 ++++++++++++++++++++++++++-------
 sys/arch/alpha/pci/pci_sgmap_pte32.c  |    5 +-
 sys/arch/alpha/pci/pci_sgmap_pte64.c  |    5 +-
 sys/arch/alpha/tc/tc_dma.c            |    5 +-
 sys/arch/alpha/tc/tc_dma_3000_500.c   |   17 +---
 sys/arch/alpha/tc/tc_sgmap.c          |    5 +-
 6 files changed, 111 insertions(+), 46 deletions(-)

diffs (truncated from 361 to 300 lines):

diff -r c139bcbb39f4 -r 3531e25cf21d sys/arch/alpha/common/sgmap_typedep.c
--- a/sys/arch/alpha/common/sgmap_typedep.c     Thu Jul 19 06:14:27 2001 +0000
+++ b/sys/arch/alpha/common/sgmap_typedep.c     Thu Jul 19 06:40:01 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sgmap_typedep.c,v 1.17 2001/07/19 04:27:37 thorpej Exp $ */
+/* $NetBSD: sgmap_typedep.c,v 1.18 2001/07/19 06:40:01 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998, 2001 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-__KERNEL_RCSID(0, "$NetBSD: sgmap_typedep.c,v 1.17 2001/07/19 04:27:37 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgmap_typedep.c,v 1.18 2001/07/19 06:40:01 thorpej Exp $");
 
 #include "opt_ddb.h"
 
@@ -47,6 +47,11 @@
 
 SGMAP_PTE_TYPE         __C(SGMAP_TYPE,_prefetch_spill_page_pte);
 
+int                    __C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t,
+                           bus_dmamap_t, void *buf, size_t buflen,
+                           struct proc *, int, int *,
+                           struct alpha_sgmap *);
+
 void
 __C(SGMAP_TYPE,_init_spill_page_pte)(void)
 {
@@ -57,8 +62,9 @@
 }
 
 int
-__C(SGMAP_TYPE,_load)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
-    bus_size_t buflen, struct proc *p, int flags, struct alpha_sgmap *sgmap)
+__C(SGMAP_TYPE,_load_buffer)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
+    size_t buflen, struct proc *p, int flags, int *segp,
+    struct alpha_sgmap *sgmap)
 {
        vaddr_t endva, va = (vaddr_t)buf;
        paddr_t pa;
@@ -67,22 +73,11 @@
        SGMAP_PTE_TYPE *pte, *page_table = sgmap->aps_pt;
        int pteidx, error, spill;
 
-       /*
-        * Initialize the spill page PTE if that hasn't already been done.
-        */
+       /* Initialize the spill page PTE if it hasn't been already. */
        if (__C(SGMAP_TYPE,_prefetch_spill_page_pte) == 0)
                __C(SGMAP_TYPE,_init_spill_page_pte)();
 
        /*
-        * Make sure that on error condition we return "no valid mappings".
-        */
-       map->dm_mapsize = 0;
-       map->dm_nsegs = 0;
-
-       if (buflen > map->_dm_size)
-               return (EINVAL);
-
-       /*
         * Remember the offset into the first page and the total
         * transfer length.
         */
@@ -133,6 +128,8 @@
 
        error = extent_alloc(sgmap->aps_ex, sgvalen, alignment, boundary,
            (flags & BUS_DMA_NOWAIT) ? EX_NOWAIT : EX_WAITOK, &sgva);
+       if (error)
+               return (error);
 
 #if 0
        printf("error %d sgva 0x%lx\n", error, sgva);
@@ -149,19 +146,18 @@
 #endif
 
        /* Generate the DMA address. */
-       map->dm_segs[0].ds_addr = sgmap->aps_wbase | sgva | dmaoffset;
-       map->dm_segs[0].ds_len = buflen;
+       map->dm_segs[*segp].ds_addr = sgmap->aps_wbase | sgva | dmaoffset;
+       map->dm_segs[*segp].ds_len = buflen;
 
 #ifdef SGMAP_DEBUG
        if (__C(SGMAP_TYPE,_debug))
                printf("sgmap_load: wbase = 0x%lx, vpage = 0x%x, "
-                   "dma addr = 0x%lx\n", sgmap->aps_wbase,
-                   (pteidx << SGMAP_ADDR_PTEIDX_SHIFT),
+                   "dma addr = 0x%lx\n", sgmap->aps_wbase, sgva,
                    map->dm_segs[0].ds_addr);
 #endif
 
        for (; va < endva; va += NBPG, pteidx++,
-            pte = &page_table[pteidx * SGMAP_PTE_SPACING]) {
+           pte = &page_table[pteidx * SGMAP_PTE_SPACING]) {
                /* Get the physical address for this segment. */
                if (p != NULL)
                        (void) pmap_extract(p->p_vmspace->vm_map.pmap, va,
@@ -191,23 +187,95 @@
 #endif
        }
 
+       return (0);
+}
+
+int
+__C(SGMAP_TYPE,_load)(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
+    bus_size_t buflen, struct proc *p, int flags, struct alpha_sgmap *sgmap)
+{
+       int seg, error;
+
+       /*
+        * Make sure that on error condition we return "no valid mappings".
+        */
+       map->dm_mapsize = 0;
+       map->dm_nsegs = 0;
+
+       if (buflen > map->_dm_size)
+               return (EINVAL);
+
+       seg = 0;
+       error = __C(SGMAP_TYPE,_load_buffer)(t, map, buf, buflen, p,
+           flags, &seg, sgmap);
+
        alpha_mb();
 
 #if defined(SGMAP_DEBUG) && defined(DDB)
        if (__C(SGMAP_TYPE,_debug) > 1)
                Debugger();
 #endif
-       map->dm_mapsize = buflen;
-       map->dm_nsegs = 1;
-       return (0);
+
+       if (error == 0) {
+               map->dm_mapsize = buflen;
+               map->dm_nsegs = 1;
+       } else if (t->_next_window != NULL) {
+               /* Give the next window a chance. */
+               error = bus_dmamap_load(t->_next_window, map, buf, buflen,
+                   p, flags);
+       }
+       return (error);
 }
 
 int
 __C(SGMAP_TYPE,_load_mbuf)(bus_dma_tag_t t, bus_dmamap_t map,
-    struct mbuf *m, int flags, struct alpha_sgmap *sgmap)
+    struct mbuf *m0, int flags, struct alpha_sgmap *sgmap)
 {
+       struct mbuf *m;
+       int seg, error;
 
-       panic(__S(__C(SGMAP_TYPE,_load_mbuf)) ": not implemented");
+       /*
+        * Make sure that on error condition we return "no valid mappings".
+        */
+       map->dm_mapsize = 0;
+       map->dm_nsegs = 0;
+
+#ifdef DIAGNOSTIC
+       if ((m0->m_flags & M_PKTHDR) == 0)
+               panic(__S(__C(SGMAP_TYPE,_load_mbuf)) ": no packet header");
+#endif
+
+       if (m0->m_pkthdr.len > map->_dm_size)
+               return (EINVAL);
+
+       seg = 0;
+       error = 0;
+       for (m = m0; m != NULL && error == 0; m = m->m_next, seg++)
+               error = __C(SGMAP_TYPE,_load_buffer)(t, map,
+                   m->m_data, m->m_len, NULL, flags, &seg, sgmap);
+
+       alpha_mb();
+
+#if defined(SGMAP_DEBUG) && defined(DDB)
+       if (__C(SGMAP_TYPE,_debug) > 1)
+               Debugger();
+#endif
+
+       if (error == 0) {
+               map->dm_mapsize = m0->m_pkthdr.len;
+               map->dm_nsegs = seg;
+       } else {
+               /* Need to back out what we've done so far. */
+               map->dm_nsegs = seg - 1;
+               __C(SGMAP_TYPE,_unload)(t, map, sgmap);
+               if (t->_next_window != NULL) {
+                       /* Give the next window a chance. */
+                       error = bus_dmamap_load_mbuf(t->_next_window, map,
+                           m0, flags);
+               }
+       }
+
+       return (error);
 }
 
 int
diff -r c139bcbb39f4 -r 3531e25cf21d sys/arch/alpha/pci/pci_sgmap_pte32.c
--- a/sys/arch/alpha/pci/pci_sgmap_pte32.c      Thu Jul 19 06:14:27 2001 +0000
+++ b/sys/arch/alpha/pci/pci_sgmap_pte32.c      Thu Jul 19 06:40:01 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_sgmap_pte32.c,v 1.4 2000/06/29 08:58:49 mrg Exp $ */
+/* $NetBSD: pci_sgmap_pte32.c,v 1.5 2001/07/19 06:40:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -39,13 +39,14 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(1, "$NetBSD: pci_sgmap_pte32.c,v 1.4 2000/06/29 08:58:49 mrg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: pci_sgmap_pte32.c,v 1.5 2001/07/19 06:40:02 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
+#include <sys/mbuf.h>
 #include <sys/proc.h>
 
 #include <uvm/uvm_extern.h>
diff -r c139bcbb39f4 -r 3531e25cf21d sys/arch/alpha/pci/pci_sgmap_pte64.c
--- a/sys/arch/alpha/pci/pci_sgmap_pte64.c      Thu Jul 19 06:14:27 2001 +0000
+++ b/sys/arch/alpha/pci/pci_sgmap_pte64.c      Thu Jul 19 06:40:01 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_sgmap_pte64.c,v 1.4 2000/06/29 08:58:49 mrg Exp $ */
+/* $NetBSD: pci_sgmap_pte64.c,v 1.5 2001/07/19 06:40:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -39,13 +39,14 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(1, "$NetBSD: pci_sgmap_pte64.c,v 1.4 2000/06/29 08:58:49 mrg Exp $");
+__KERNEL_RCSID(1, "$NetBSD: pci_sgmap_pte64.c,v 1.5 2001/07/19 06:40:02 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/device.h>
 #include <sys/malloc.h>
+#include <sys/mbuf.h>
 #include <sys/proc.h>
 
 #include <uvm/uvm_extern.h>
diff -r c139bcbb39f4 -r 3531e25cf21d sys/arch/alpha/tc/tc_dma.c
--- a/sys/arch/alpha/tc/tc_dma.c        Thu Jul 19 06:14:27 2001 +0000
+++ b/sys/arch/alpha/tc/tc_dma.c        Thu Jul 19 06:40:01 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tc_dma.c,v 1.9 1998/08/14 16:50:05 thorpej Exp $ */
+/* $NetBSD: tc_dma.c,v 1.10 2001/07/19 06:40:02 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: tc_dma.c,v 1.9 1998/08/14 16:50:05 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tc_dma.c,v 1.10 2001/07/19 06:40:02 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -56,6 +56,7 @@
        NULL,                           /* _next_window */
        0,                              /* _boundary */
        NULL,                           /* _sgmap */
+       0,                              /* _pfthresh */
        NULL,                           /* _get_tag */
        _bus_dmamap_create,
        _bus_dmamap_destroy,
diff -r c139bcbb39f4 -r 3531e25cf21d sys/arch/alpha/tc/tc_dma_3000_500.c
--- a/sys/arch/alpha/tc/tc_dma_3000_500.c       Thu Jul 19 06:14:27 2001 +0000
+++ b/sys/arch/alpha/tc/tc_dma_3000_500.c       Thu Jul 19 06:40:01 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tc_dma_3000_500.c,v 1.12 2001/07/12 23:35:43 thorpej Exp $ */
+/* $NetBSD: tc_dma_3000_500.c,v 1.13 2001/07/19 06:40:03 thorpej Exp $ */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 
 #include <sys/cdefs.h>                 /* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: tc_dma_3000_500.c,v 1.12 2001/07/12 23:35:43 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tc_dma_3000_500.c,v 1.13 2001/07/19 06:40:03 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -63,6 +63,7 @@
        NULL,                           /* _next_window */
        0,                              /* _boundary */
        NULL,                           /* _sgmap */
+       0,                              /* _pfthresh */
        NULL,                           /* _get_tag */



Home | Main Index | Thread Index | Old Index