| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_ipw.c,v 1.53 2012/01/30 19:41:20 drochner Exp $ */ | | 1 | /* $NetBSD: if_ipw.c,v 1.53.2.1 2017/08/18 14:58:15 snj Exp $ */ |
2 | /* FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp */ | | 2 | /* FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.15 2005/11/13 17:17:40 damien Exp */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 2004, 2005 | | 5 | * Copyright (c) 2004, 2005 |
6 | * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. | | 6 | * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice unmodified, this list of conditions, and the following | | 12 | * notice unmodified, this list of conditions, and the following |
13 | * disclaimer. | | 13 | * disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -19,27 +19,27 @@ | | | @@ -19,27 +19,27 @@ |
19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | | 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 | * SUCH DAMAGE. | | 28 | * SUCH DAMAGE. |
29 | */ | | 29 | */ |
30 | | | 30 | |
31 | #include <sys/cdefs.h> | | 31 | #include <sys/cdefs.h> |
32 | __KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.53 2012/01/30 19:41:20 drochner Exp $"); | | 32 | __KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.53.2.1 2017/08/18 14:58:15 snj Exp $"); |
33 | | | 33 | |
34 | /*- | | 34 | /*- |
35 | * Intel(R) PRO/Wireless 2100 MiniPCI driver | | 35 | * Intel(R) PRO/Wireless 2100 MiniPCI driver |
36 | * http://www.intel.com/network/connectivity/products/wireless/prowireless_mobile.htm | | 36 | * http://www.intel.com/network/connectivity/products/wireless/prowireless_mobile.htm |
37 | */ | | 37 | */ |
38 | | | 38 | |
39 | | | 39 | |
40 | #include <sys/param.h> | | 40 | #include <sys/param.h> |
41 | #include <sys/sockio.h> | | 41 | #include <sys/sockio.h> |
42 | #include <sys/sysctl.h> | | 42 | #include <sys/sysctl.h> |
43 | #include <sys/mbuf.h> | | 43 | #include <sys/mbuf.h> |
44 | #include <sys/kernel.h> | | 44 | #include <sys/kernel.h> |
45 | #include <sys/socket.h> | | 45 | #include <sys/socket.h> |
| @@ -580,46 +580,50 @@ ipw_dma_alloc(struct ipw_softc *sc) | | | @@ -580,46 +580,50 @@ ipw_dma_alloc(struct ipw_softc *sc) |
580 | sbuf = &sc->rx_sbuf_list[i]; | | 580 | sbuf = &sc->rx_sbuf_list[i]; |
581 | sbd->bd = &sc->rbd_list[i]; | | 581 | sbd->bd = &sc->rbd_list[i]; |
582 | | | 582 | |
583 | MGETHDR(sbuf->m, M_DONTWAIT, MT_DATA); | | 583 | MGETHDR(sbuf->m, M_DONTWAIT, MT_DATA); |
584 | if (sbuf->m == NULL) { | | 584 | if (sbuf->m == NULL) { |
585 | aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf\n"); | | 585 | aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf\n"); |
586 | error = ENOMEM; | | 586 | error = ENOMEM; |
587 | goto fail; | | 587 | goto fail; |
588 | } | | 588 | } |
589 | | | 589 | |
590 | MCLGET(sbuf->m, M_DONTWAIT); | | 590 | MCLGET(sbuf->m, M_DONTWAIT); |
591 | if (!(sbuf->m->m_flags & M_EXT)) { | | 591 | if (!(sbuf->m->m_flags & M_EXT)) { |
592 | m_freem(sbuf->m); | | 592 | m_freem(sbuf->m); |
| | | 593 | sbuf->m = NULL; |
593 | aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf cluster\n"); | | 594 | aprint_error_dev(&sc->sc_dev, "could not allocate rx mbuf cluster\n"); |
594 | error = ENOMEM; | | 595 | error = ENOMEM; |
595 | goto fail; | | 596 | goto fail; |
596 | } | | 597 | } |
597 | | | 598 | |
598 | sbuf->m->m_pkthdr.len = sbuf->m->m_len = sbuf->m->m_ext.ext_size; | | 599 | sbuf->m->m_pkthdr.len = sbuf->m->m_len = sbuf->m->m_ext.ext_size; |
599 | | | 600 | |
600 | error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, | | 601 | error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, |
601 | 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &sbuf->map); | | 602 | 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &sbuf->map); |
602 | if (error != 0) { | | 603 | if (error != 0) { |
603 | aprint_error_dev(&sc->sc_dev, "could not create rxbuf dma map\n"); | | 604 | aprint_error_dev(&sc->sc_dev, "could not create rxbuf dma map\n"); |
604 | m_freem(sbuf->m); | | 605 | m_freem(sbuf->m); |
| | | 606 | sbuf->m = NULL; |
605 | goto fail; | | 607 | goto fail; |
606 | } | | 608 | } |
607 | | | 609 | |
608 | error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, | | 610 | error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, |
609 | sbuf->m, BUS_DMA_READ | BUS_DMA_NOWAIT); | | 611 | sbuf->m, BUS_DMA_READ | BUS_DMA_NOWAIT); |
610 | if (error != 0) { | | 612 | if (error != 0) { |
611 | bus_dmamap_destroy(sc->sc_dmat, sbuf->map); | | 613 | bus_dmamap_destroy(sc->sc_dmat, sbuf->map); |
| | | 614 | sbuf->map = NULL; |
612 | m_freem(sbuf->m); | | 615 | m_freem(sbuf->m); |
| | | 616 | sbuf->m = NULL; |
613 | aprint_error_dev(&sc->sc_dev, "could not map rxbuf dma memory\n"); | | 617 | aprint_error_dev(&sc->sc_dev, "could not map rxbuf dma memory\n"); |
614 | goto fail; | | 618 | goto fail; |
615 | } | | 619 | } |
616 | | | 620 | |
617 | sbd->type = IPW_SBD_TYPE_DATA; | | 621 | sbd->type = IPW_SBD_TYPE_DATA; |
618 | sbd->priv = sbuf; | | 622 | sbd->priv = sbuf; |
619 | sbd->bd->physaddr = htole32(sbuf->map->dm_segs[0].ds_addr); | | 623 | sbd->bd->physaddr = htole32(sbuf->map->dm_segs[0].ds_addr); |
620 | sbd->bd->len = htole32(MCLBYTES); | | 624 | sbd->bd->len = htole32(MCLBYTES); |
621 | | | 625 | |
622 | bus_dmamap_sync(sc->sc_dmat, sbuf->map, 0, | | 626 | bus_dmamap_sync(sc->sc_dmat, sbuf->map, 0, |
623 | sbuf->map->dm_mapsize, BUS_DMASYNC_PREREAD); | | 627 | sbuf->map->dm_mapsize, BUS_DMASYNC_PREREAD); |
624 | | | 628 | |
625 | } | | 629 | } |