The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/pci/if_lmc_nbsd.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: if_lmc_nbsd.c,v 1.21 2003/04/01 02:04:34 thorpej Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1997-1999 LAN Media Corporation (LMC)
    5  * All rights reserved.  www.lanmedia.com
    6  *
    7  * This code is written by Michael Graff <graff@vix.com> for LMC.
    8  * The code is derived from permitted modifications to software created
    9  * by Matt Thomas (matt@3am-software.com).
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above
   17  *    copyright notice, this list of conditions and the following disclaimer
   18  *    in the documentation and/or other materials provided with the
   19  *    distribution.
   20  * 3. All marketing or advertising materials mentioning features or
   21  *    use of this software must display the following acknowledgement:
   22  *      This product includes software developed by LAN Media Corporation
   23  *      and its contributors.
   24  * 4. Neither the name of LAN Media Corporation nor the names of its
   25  *    contributors may be used to endorse or promote products derived
   26  *    from this software without specific prior written permission.
   27  *
   28  * THIS SOFTWARE IS PROVIDED BY LAN MEDIA CORPORATION AND CONTRIBUTORS
   29  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   31  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   32  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   33  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   34  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   35  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   36  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   37  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
   38  * THE POSSIBILITY OF SUCH DAMAGE.
   39  */
   40 
   41 /*-
   42  * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
   43  * All rights reserved.
   44  *
   45  * Redistribution and use in source and binary forms, with or without
   46  * modification, are permitted provided that the following conditions
   47  * are met:
   48  * 1. Redistributions of source code must retain the above copyright
   49  *    notice, this list of conditions and the following disclaimer.
   50  * 2. The name of the author may not be used to endorse or promote products
   51  *    derived from this software without specific prior written permission
   52  *
   53  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   54  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   55  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   56  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   57  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   58  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   59  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   60  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   61  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   62  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   63  */
   64 
   65 #include <sys/cdefs.h>
   66 __KERNEL_RCSID(0, "$NetBSD: if_lmc_nbsd.c,v 1.21 2003/04/01 02:04:34 thorpej Exp $");
   67 
   68 #include <sys/param.h>
   69 #include <sys/systm.h>
   70 #include <sys/mbuf.h>
   71 #include <sys/socket.h>
   72 #include <sys/ioctl.h>
   73 #include <sys/errno.h>
   74 #include <sys/malloc.h>
   75 #include <sys/kernel.h>
   76 #include <sys/proc.h>   /* only for declaration of wakeup() used by vm.h */
   77 #if defined(__FreeBSD__)
   78 #include <machine/clock.h>
   79 #elif defined(__bsdi__) || defined(__NetBSD__)
   80 #include <sys/device.h>
   81 #endif
   82 
   83 #if defined(__NetBSD__)
   84 #include <dev/pci/pcidevs.h>
   85 #include "rnd.h"
   86 #if NRND > 0
   87 #include <sys/rnd.h>
   88 #endif
   89 #endif
   90 
   91 #include <net/if.h>
   92 #include <net/if_types.h>
   93 #include <net/if_dl.h>
   94 #include <net/netisr.h>
   95 
   96 #include "bpfilter.h"
   97 #if NBPFILTER > 0
   98 #include <net/bpf.h>
   99 #include <net/bpfdesc.h>
  100 #endif
  101 
  102 #if defined(__FreeBSD__)
  103 #include <net/if_sppp.h>
  104 #elif defined(__NetBSD__)
  105 #include <net/if_spppvar.h>
  106 #endif
  107 
  108 #if defined(__bsdi__)
  109 #if INET
  110 #include <netinet/in.h>
  111 #include <netinet/in_systm.h>
  112 #include <netinet/ip.h>
  113 #endif
  114 
  115 #include <net/netisr.h>
  116 #include <net/if.h>
  117 #include <net/netisr.h>
  118 #include <net/if_types.h>
  119 #include <net/if_p2p.h>
  120 #include <net/if_c_hdlc.h>
  121 #endif
  122 
  123 #if defined(__FreeBSD__)
  124 #include <vm/vm.h>
  125 #include <vm/pmap.h>
  126 #include <pci.h>
  127 #if NPCI > 0
  128 #include <pci/pcivar.h>
  129 #include <pci/dc21040reg.h>
  130 #endif
  131 #endif /* __FreeBSD__ */
  132 
  133 #if defined(__bsdi__)
  134 #include <vm/vm.h>
  135 #include <i386/pci/ic/dc21040.h>
  136 #include <i386/isa/isa.h>
  137 #include <i386/isa/icu.h>
  138 #include <i386/isa/dma.h>
  139 #include <i386/isa/isavar.h>
  140 #include <i386/pci/pci.h>
  141 #endif /* __bsdi__ */
  142 
  143 #if defined(__NetBSD__)
  144 #include <uvm/uvm_extern.h>
  145 #include <machine/bus.h>
  146 #if defined(__alpha__)
  147 #include <machine/intr.h>
  148 #endif
  149 #include <dev/pci/pcireg.h>
  150 #include <dev/pci/pcivar.h>
  151 #include <dev/ic/dc21040reg.h>
  152 #endif /* __NetBSD__ */
  153 
  154 /*
  155  * Sigh.  Every OS puts these in different places.
  156  */
  157 #if defined(__NetBSD__)
  158 #include <dev/pci/if_lmc_types.h>
  159 #include <dev/pci/if_lmcioctl.h>
  160 #include <dev/pci/if_lmcvar.h>  
  161 #elif defined(__FreeBSD__)
  162 #include "pci/if_lmc_types.h"
  163 #include "pci/if_lmcioctl.h"
  164 #include "pci/if_lmcvar.h"
  165 #else /* BSDI */
  166 #include "i386/pci/if_lmctypes.h"
  167 #include "i386/pci/if_lmcioctl.h"
  168 #include "i386/pci/if_lmcvar.h" 
  169 #endif
  170 
  171 /*
  172  * This file is INCLUDED (gross, I know, but...)
  173  */
  174 
  175 static void lmc_shutdown(void *arg);
  176 static int lmc_busdma_init(lmc_softc_t * const sc);
  177 static int lmc_busdma_allocmem(lmc_softc_t * const sc, size_t size,
  178         bus_dmamap_t *map_p, lmc_desc_t **desc_p);
  179 
  180 static int
  181 lmc_pci_probe(struct device *parent, struct cfdata *match,
  182               void *aux)
  183 {
  184         struct pci_attach_args *pa = (struct pci_attach_args *)aux;
  185         u_int32_t id;
  186 
  187         /*
  188          * check first for the DEC chip we expect to find.  We expect
  189          * 21140A, pass 2.2 or higher.
  190          */
  191         if (PCI_VENDORID(pa->pa_id) != PCI_VENDOR_DEC)
  192                 return 0;
  193         if (PCI_CHIPID(pa->pa_id) != PCI_PRODUCT_DEC_21140)
  194                 return 0;
  195         id = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CFRV) & 0xff;
  196         if (id < 0x22)
  197                 return 0;
  198 
  199         /*
  200          * Next, check the subsystem ID and see if it matches what we
  201          * expect.
  202          */
  203         id = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SSID);
  204         if (PCI_VENDORID(id) != PCI_VENDOR_LMC)
  205                 return 0;
  206         if ((PCI_CHIPID(id) != PCI_PRODUCT_LMC_HSSI)
  207             && (PCI_CHIPID(id) != PCI_PRODUCT_LMC_DS3)
  208             && (PCI_CHIPID(id) != PCI_PRODUCT_LMC_SSI)
  209             && (PCI_CHIPID(id) != PCI_PRODUCT_LMC_DS1))
  210                 return 0;
  211 
  212         return 20; /* must be > than any other tulip driver */
  213 }
  214 
  215 static void  lmc_pci_attach(struct device * const parent,
  216                              struct device * const self, void * const aux);
  217 
  218 CFATTACH_DECL(lmc, sizeof(lmc_softc_t),
  219     lmc_pci_probe, lmc_pci_attach, NULL, NULL);
  220 
  221 static void
  222 lmc_pci_attach(struct device * const parent,
  223                 struct device * const self, void * const aux)
  224 {
  225         u_int32_t revinfo, cfdainfo, id, ssid;
  226         pci_intr_handle_t intrhandle;
  227         const char *intrstr;
  228         unsigned csroffset = LMC_PCI_CSROFFSET;
  229         unsigned csrsize = LMC_PCI_CSRSIZE;
  230         lmc_csrptr_t csr_base;
  231         lmc_spl_t s;
  232         lmc_intrfunc_t (*intr_rtn)(void *) = lmc_intr_normal;
  233         lmc_softc_t * const sc = (lmc_softc_t *) self;
  234         struct pci_attach_args * const pa = (struct pci_attach_args *) aux;
  235         extern lmc_media_t lmc_hssi_media;
  236         extern lmc_media_t lmc_ds3_media;
  237         extern lmc_media_t lmc_t1_media;
  238         extern lmc_media_t lmc_ssi_media;
  239 
  240         revinfo  = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CFRV) & 0xFF;
  241         id       = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CFID);
  242         cfdainfo = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_CFDA);
  243         ssid = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_SSID);
  244 
  245         switch (PCI_CHIPID(ssid)) {
  246         case PCI_PRODUCT_LMC_HSSI:
  247                 printf(": Lan Media Corporation HSSI\n");
  248                 sc->lmc_media = &lmc_hssi_media;
  249                 break;
  250         case PCI_PRODUCT_LMC_DS3:
  251                 printf(": Lan Media Corporation DS3\n");
  252                 sc->lmc_media = &lmc_ds3_media;
  253                 break;
  254         case PCI_PRODUCT_LMC_SSI:
  255                 printf(": Lan Media Corporation SSI\n");
  256                 sc->lmc_media = &lmc_ssi_media;
  257                 break;
  258         case PCI_PRODUCT_LMC_DS1:
  259                 printf(": Lan Media Corporation T1\n");
  260                 sc->lmc_media = &lmc_t1_media;
  261                 break;
  262         }
  263 
  264         sc->lmc_pci_busno = parent;
  265         sc->lmc_pci_devno = pa->pa_device;
  266 
  267         sc->lmc_chipid = LMC_21140A;
  268         sc->lmc_features |= LMC_HAVE_STOREFWD;
  269         if (sc->lmc_chipid == LMC_21140A && revinfo <= 0x22)
  270                 sc->lmc_features |= LMC_HAVE_RXBADOVRFLW;
  271 
  272         if (cfdainfo & (TULIP_CFDA_SLEEP | TULIP_CFDA_SNOOZE)) {
  273                 cfdainfo &= ~(TULIP_CFDA_SLEEP | TULIP_CFDA_SNOOZE);
  274                 pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_CFDA, cfdainfo);
  275                 DELAY(11 * 1000);
  276         }
  277 
  278         strcpy(sc->lmc_if.if_xname, self->dv_xname);
  279         sc->lmc_if.if_softc = sc;
  280         sc->lmc_pc = pa->pa_pc;
  281 
  282         sc->lmc_revinfo = revinfo;
  283         sc->lmc_if.if_softc = sc;
  284 
  285         csr_base = 0;
  286         {
  287                 bus_space_tag_t iot, memt;
  288                 bus_space_handle_t ioh, memh;
  289                 int ioh_valid, memh_valid;
  290 
  291                 ioh_valid = (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO,
  292                                             0, &iot, &ioh, NULL, NULL) == 0);
  293                 memh_valid = (pci_mapreg_map(pa, PCI_CBMA,
  294                                              PCI_MAPREG_TYPE_MEM |
  295                                              PCI_MAPREG_MEM_TYPE_32BIT,
  296                                              0, &memt, &memh, NULL,
  297                                              NULL) == 0);
  298                 if (memh_valid) {
  299                         sc->lmc_bustag = memt;
  300                         sc->lmc_bushandle = memh;
  301                 } else if (ioh_valid) {
  302                         sc->lmc_bustag = iot;
  303                         sc->lmc_bushandle = ioh;
  304                 } else {
  305                         printf("%s: unable to map device registers\n",
  306                                sc->lmc_dev.dv_xname);
  307                         return;
  308                 }
  309                 /* Make sure bus mastering is enabled. */
  310                 pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
  311                                pci_conf_read(pa->pa_pc, pa->pa_tag,
  312                                              PCI_COMMAND_STATUS_REG) |
  313                                PCI_COMMAND_MASTER_ENABLE);
  314         }
  315 
  316 #if defined(LMC_BUS_DMA)
  317         sc->lmc_dmatag = pa->pa_dmat;
  318         if ((lmc_busdma_init(sc)) != 0) {
  319                 printf("error initing bus_dma\n");
  320                 return;
  321         }
  322 #else
  323         sc->lmc_txdescs = (lmc_desc_t *)
  324                 malloc((LMC_TXDESCS+LMC_RXDESCS)*sizeof(lmc_desc_t),
  325                         M_DEVBUF, M_WAITOK);
  326         sc->lmc_rxdescs = sc->lmc_txdescs + LMC_TXDESCS;
  327 #endif
  328         lmc_initcsrs(sc, csr_base + csroffset, csrsize);
  329         lmc_initring(sc, &sc->lmc_rxinfo, sc->lmc_rxdescs,
  330                        LMC_RXDESCS);
  331         lmc_initring(sc, &sc->lmc_txinfo, sc->lmc_txdescs,
  332                        LMC_TXDESCS);
  333 
  334         lmc_gpio_mkinput(sc, 0xff);
  335         sc->lmc_gpio = 0;  /* drive no signals yet */
  336 
  337         sc->lmc_media->defaults(sc);
  338 
  339         sc->lmc_media->set_link_status(sc, LMC_LINK_DOWN); /* down */
  340 
  341         /*
  342          * Make sure there won't be any interrupts or such...
  343          */
  344         LMC_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
  345 
  346         /*
  347          * Wait 10 microseconds (actually 50 PCI cycles but at 
  348          * 33MHz that comes to two microseconds but wait a
  349          * bit longer anyways)
  350          */
  351         DELAY(100);
  352 
  353         lmc_read_macaddr(sc);
  354 
  355         if (pci_intr_map(pa, &intrhandle)) {
  356                 printf("%s: couldn't map interrupt\n",
  357                        sc->lmc_dev.dv_xname);
  358                 return;
  359         }
  360         intrstr = pci_intr_string(pa->pa_pc, intrhandle);
  361         sc->lmc_ih = pci_intr_establish(pa->pa_pc, intrhandle,
  362                                           IPL_NET, intr_rtn, sc);
  363         if (sc->lmc_ih == NULL) {
  364                 printf("%s: couldn't establish interrupt",
  365                        sc->lmc_dev.dv_xname);
  366                 if (intrstr != NULL)
  367                         printf(" at %s", intrstr);
  368                 printf("\n");
  369                 return;
  370         }
  371         printf("%s: interrupting at %s\n", sc->lmc_dev.dv_xname, intrstr);
  372 
  373         printf("%s: pass %d.%d, serial " LMC_EADDR_FMT ", %s\n",
  374                sc->lmc_dev.dv_xname,
  375                (sc->lmc_revinfo & 0xF0) >> 4, sc->lmc_revinfo & 0x0F,
  376                LMC_EADDR_ARGS(sc->lmc_enaddr), intrstr);
  377 
  378         sc->lmc_ats = shutdownhook_establish(lmc_shutdown, sc);
  379         if (sc->lmc_ats == NULL)
  380                 printf("%s: warning: couldn't establish shutdown hook\n",
  381                        sc->lmc_xname);
  382 
  383         s = LMC_RAISESPL();
  384         lmc_dec_reset(sc);
  385         lmc_reset(sc);
  386         lmc_attach(sc);
  387         LMC_RESTORESPL(s);
  388 }
  389 
  390 static void
  391 lmc_shutdown(void *arg)
  392 {
  393         lmc_softc_t * const sc = arg;
  394         LMC_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
  395         DELAY(10);
  396 
  397         sc->lmc_miireg16 = 0;  /* deassert ready, and all others too */
  398         lmc_led_on(sc, LMC_MII16_LED_ALL);
  399 
  400         sppp_flush(&sc->lmc_if);
  401 }
  402 
  403 #if defined(LMC_BUS_DMA)
  404 #if !defined(LMC_BUS_DMA_NOTX) || !defined(LMC_BUS_DMA_NORX)
  405 static int
  406 lmc_busdma_allocmem(
  407     lmc_softc_t * const sc,
  408     size_t size,
  409     bus_dmamap_t *map_p,
  410     lmc_desc_t **desc_p)
  411 {
  412     bus_dma_segment_t segs[1];
  413     int nsegs, error;
  414     error = bus_dmamem_alloc(sc->lmc_dmatag, size, 1, PAGE_SIZE,
  415                              segs, sizeof(segs)/sizeof(segs[0]),
  416                              &nsegs, BUS_DMA_NOWAIT);
  417     if (error == 0) {
  418         void *desc;
  419         error = bus_dmamem_map(sc->lmc_dmatag, segs, nsegs, size,
  420                                (void *) &desc, BUS_DMA_NOWAIT|BUS_DMA_COHERENT);
  421         if (error == 0) {
  422             bus_dmamap_t map;
  423             error = bus_dmamap_create(sc->lmc_dmatag, size, 1, size, 0,
  424                                       BUS_DMA_NOWAIT, &map);
  425             if (error == 0) {
  426                 error = bus_dmamap_load(sc->lmc_dmatag, map, desc,
  427                                         size, NULL, BUS_DMA_NOWAIT);
  428                 if (error)
  429                     bus_dmamap_destroy(sc->lmc_dmatag, map);
  430                 else
  431                     *map_p = map;
  432             }
  433             if (error)
  434                 bus_dmamem_unmap(sc->lmc_dmatag, desc, size);
  435         }
  436         if (error)
  437             bus_dmamem_free(sc->lmc_dmatag, segs, nsegs);
  438         else
  439             *desc_p = desc;
  440     }
  441     return error;
  442 }
  443 #endif
  444 
  445 static int
  446 lmc_busdma_init(
  447     lmc_softc_t * const sc)
  448 {
  449     int error = 0;
  450 
  451 #if !defined(LMC_BUS_DMA_NOTX)
  452     /*
  453      * Allocate space and dmamap for transmit ring
  454      */
  455     if (error == 0) {
  456         error = lmc_busdma_allocmem(sc, sizeof(lmc_desc_t) * LMC_TXDESCS,
  457                                       &sc->lmc_txdescmap,
  458                                       &sc->lmc_txdescs);
  459     }
  460 
  461     /*
  462      * Allocate dmamaps for each transmit descriptors
  463      */
  464     if (error == 0) {
  465         while (error == 0 && sc->lmc_txmaps_free < LMC_TXDESCS) {
  466             bus_dmamap_t map;
  467             if ((error = LMC_TXMAP_CREATE(sc, &map)) == 0)
  468                 sc->lmc_txmaps[sc->lmc_txmaps_free++] = map;
  469         }
  470         if (error) {
  471             while (sc->lmc_txmaps_free > 0) 
  472                 bus_dmamap_destroy(sc->lmc_dmatag,
  473                                    sc->lmc_txmaps[--sc->lmc_txmaps_free]);
  474         }
  475     }
  476 #else
  477     if (error == 0) {
  478         sc->lmc_txdescs = (lmc_desc_t *) malloc(LMC_TXDESCS * sizeof(lmc_desc_t), M_DEVBUF, M_NOWAIT);
  479         if (sc->lmc_txdescs == NULL)
  480             error = ENOMEM;
  481     }
  482 #endif
  483 #if !defined(LMC_BUS_DMA_NORX)
  484     /*
  485      * Allocate space and dmamap for receive ring
  486      */
  487     if (error == 0) {
  488         error = lmc_busdma_allocmem(sc, sizeof(lmc_desc_t) * LMC_RXDESCS,
  489                                       &sc->lmc_rxdescmap,
  490                                       &sc->lmc_rxdescs);
  491     }
  492 
  493     /*
  494      * Allocate dmamaps for each receive descriptors
  495      */
  496     if (error == 0) {
  497         while (error == 0 && sc->lmc_rxmaps_free < LMC_RXDESCS) {
  498             bus_dmamap_t map;
  499             if ((error = LMC_RXMAP_CREATE(sc, &map)) == 0)
  500                 sc->lmc_rxmaps[sc->lmc_rxmaps_free++] = map;
  501         }
  502         if (error) {
  503             while (sc->lmc_rxmaps_free > 0) 
  504                 bus_dmamap_destroy(sc->lmc_dmatag,
  505                                    sc->lmc_rxmaps[--sc->lmc_rxmaps_free]);
  506         }
  507     }
  508 #else
  509     if (error == 0) {
  510         sc->lmc_rxdescs = (lmc_desc_t *) malloc(LMC_RXDESCS * sizeof(lmc_desc_t), M_DEVBUF, M_NOWAIT);
  511         if (sc->lmc_rxdescs == NULL)
  512             error = ENOMEM;
  513     }
  514 #endif
  515     return error;
  516 }
  517 #endif /* LMC_BUS_DMA */

Cache object: 174828af41769c7718d131c2f1ffe787


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.