Adopt <net/if_stats.h>.diff -r1.72 -r1.73 src/sys/dev/pci/if_ipw.c
(thorpej)
--- src/sys/dev/pci/if_ipw.c 2019/02/03 03:19:27 1.72
+++ src/sys/dev/pci/if_ipw.c 2020/01/30 06:03:34 1.73
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ipw.c,v 1.72 2019/02/03 03:19:27 mrg Exp $ */ | 1 | /* $NetBSD: if_ipw.c,v 1.73 2020/01/30 06:03:34 thorpej 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.72 2019/02/03 03:19:27 mrg Exp $"); | 32 | __KERNEL_RCSID(0, "$NetBSD: if_ipw.c,v 1.73 2020/01/30 06:03:34 thorpej 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> | |
@@ -1025,59 +1025,59 @@ ipw_data_intr(struct ipw_softc *sc, stru | @@ -1025,59 +1025,59 @@ ipw_data_intr(struct ipw_softc *sc, stru | |||
1025 | if (le32toh(status->len) < sizeof (struct ieee80211_frame_min) || | 1025 | if (le32toh(status->len) < sizeof (struct ieee80211_frame_min) || | |
1026 | le32toh(status->len) > MCLBYTES) | 1026 | le32toh(status->len) > MCLBYTES) | |
1027 | return; | 1027 | return; | |
1028 | 1028 | |||
1029 | /* | 1029 | /* | |
1030 | * Try to allocate a new mbuf for this ring element and load it before | 1030 | * Try to allocate a new mbuf for this ring element and load it before | |
1031 | * processing the current mbuf. If the ring element cannot be loaded, | 1031 | * processing the current mbuf. If the ring element cannot be loaded, | |
1032 | * drop the received packet and reuse the old mbuf. In the unlikely | 1032 | * drop the received packet and reuse the old mbuf. In the unlikely | |
1033 | * case that the old mbuf can't be reloaded either, explicitly panic. | 1033 | * case that the old mbuf can't be reloaded either, explicitly panic. | |
1034 | */ | 1034 | */ | |
1035 | MGETHDR(mnew, M_DONTWAIT, MT_DATA); | 1035 | MGETHDR(mnew, M_DONTWAIT, MT_DATA); | |
1036 | if (mnew == NULL) { | 1036 | if (mnew == NULL) { | |
1037 | aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf\n"); | 1037 | aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf\n"); | |
1038 | ifp->if_ierrors++; | 1038 | if_statinc(ifp, if_ierrors); | |
1039 | return; | 1039 | return; | |
1040 | } | 1040 | } | |
1041 | 1041 | |||
1042 | MCLGET(mnew, M_DONTWAIT); | 1042 | MCLGET(mnew, M_DONTWAIT); | |
1043 | if (!(mnew->m_flags & M_EXT)) { | 1043 | if (!(mnew->m_flags & M_EXT)) { | |
1044 | aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf cluster\n"); | 1044 | aprint_error_dev(sc->sc_dev, "could not allocate rx mbuf cluster\n"); | |
1045 | m_freem(mnew); | 1045 | m_freem(mnew); | |
1046 | ifp->if_ierrors++; | 1046 | if_statinc(ifp, if_ierrors); | |
1047 | return; | 1047 | return; | |
1048 | } | 1048 | } | |
1049 | 1049 | |||
1050 | mnew->m_pkthdr.len = mnew->m_len = mnew->m_ext.ext_size; | 1050 | mnew->m_pkthdr.len = mnew->m_len = mnew->m_ext.ext_size; | |
1051 | 1051 | |||
1052 | bus_dmamap_sync(sc->sc_dmat, sbuf->map, 0, le32toh(status->len), | 1052 | bus_dmamap_sync(sc->sc_dmat, sbuf->map, 0, le32toh(status->len), | |
1053 | BUS_DMASYNC_POSTREAD); | 1053 | BUS_DMASYNC_POSTREAD); | |
1054 | bus_dmamap_unload(sc->sc_dmat, sbuf->map); | 1054 | bus_dmamap_unload(sc->sc_dmat, sbuf->map); | |
1055 | 1055 | |||
1056 | error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, mnew, | 1056 | error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, mnew, | |
1057 | BUS_DMA_READ | BUS_DMA_NOWAIT); | 1057 | BUS_DMA_READ | BUS_DMA_NOWAIT); | |
1058 | if (error != 0) { | 1058 | if (error != 0) { | |
1059 | aprint_error_dev(sc->sc_dev, "could not load rx buf DMA map\n"); | 1059 | aprint_error_dev(sc->sc_dev, "could not load rx buf DMA map\n"); | |
1060 | m_freem(mnew); | 1060 | m_freem(mnew); | |
1061 | 1061 | |||
1062 | /* try to reload the old mbuf */ | 1062 | /* try to reload the old mbuf */ | |
1063 | error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, | 1063 | error = bus_dmamap_load_mbuf(sc->sc_dmat, sbuf->map, | |
1064 | sbuf->m, BUS_DMA_READ | BUS_DMA_NOWAIT); | 1064 | sbuf->m, BUS_DMA_READ | BUS_DMA_NOWAIT); | |
1065 | if (error != 0) { | 1065 | if (error != 0) { | |
1066 | /* very unlikely that it will fail... */ | 1066 | /* very unlikely that it will fail... */ | |
1067 | panic("%s: unable to remap rx buf", | 1067 | panic("%s: unable to remap rx buf", | |
1068 | device_xname(sc->sc_dev)); | 1068 | device_xname(sc->sc_dev)); | |
1069 | } | 1069 | } | |
1070 | ifp->if_ierrors++; | 1070 | if_statinc(ifp, if_ierrors); | |
1071 | return; | 1071 | return; | |
1072 | } | 1072 | } | |
1073 | 1073 | |||
1074 | /* | 1074 | /* | |
1075 | * New mbuf successfully loaded, update Rx ring and continue | 1075 | * New mbuf successfully loaded, update Rx ring and continue | |
1076 | * processing. | 1076 | * processing. | |
1077 | */ | 1077 | */ | |
1078 | m = sbuf->m; | 1078 | m = sbuf->m; | |
1079 | sbuf->m = mnew; | 1079 | sbuf->m = mnew; | |
1080 | sbd->bd->physaddr = htole32(sbuf->map->dm_segs[0].ds_addr); | 1080 | sbd->bd->physaddr = htole32(sbuf->map->dm_segs[0].ds_addr); | |
1081 | 1081 | |||
1082 | /* finalize mbuf */ | 1082 | /* finalize mbuf */ | |
1083 | m_set_rcvif(m, ifp); | 1083 | m_set_rcvif(m, ifp); | |
@@ -1227,27 +1227,27 @@ ipw_tx_intr(struct ipw_softc *sc) | @@ -1227,27 +1227,27 @@ ipw_tx_intr(struct ipw_softc *sc) | |||
1227 | int s; | 1227 | int s; | |
1228 | 1228 | |||
1229 | if (!(sc->flags & IPW_FLAG_FW_INITED)) | 1229 | if (!(sc->flags & IPW_FLAG_FW_INITED)) | |
1230 | return; | 1230 | return; | |
1231 | 1231 | |||
1232 | s = splnet(); | 1232 | s = splnet(); | |
1233 | 1233 | |||
1234 | r = CSR_READ_4(sc, IPW_CSR_TX_READ); | 1234 | r = CSR_READ_4(sc, IPW_CSR_TX_READ); | |
1235 | 1235 | |||
1236 | for (i = (sc->txold + 1) % IPW_NTBD; i != r; i = (i + 1) % IPW_NTBD) { | 1236 | for (i = (sc->txold + 1) % IPW_NTBD; i != r; i = (i + 1) % IPW_NTBD) { | |
1237 | sbd = &sc->stbd_list[i]; | 1237 | sbd = &sc->stbd_list[i]; | |
1238 | 1238 | |||
1239 | if (sbd->type == IPW_SBD_TYPE_DATA) | 1239 | if (sbd->type == IPW_SBD_TYPE_DATA) | |
1240 | ifp->if_opackets++; | 1240 | if_statinc(ifp, if_opackets); | |
1241 | 1241 | |||
1242 | ipw_release_sbd(sc, sbd); | 1242 | ipw_release_sbd(sc, sbd); | |
1243 | sc->txfree++; | 1243 | sc->txfree++; | |
1244 | } | 1244 | } | |
1245 | 1245 | |||
1246 | /* remember what the firmware has processed */ | 1246 | /* remember what the firmware has processed */ | |
1247 | sc->txold = (r == 0) ? IPW_NTBD - 1 : r - 1; | 1247 | sc->txold = (r == 0) ? IPW_NTBD - 1 : r - 1; | |
1248 | 1248 | |||
1249 | /* Call start() since some buffer descriptors have been released */ | 1249 | /* Call start() since some buffer descriptors have been released */ | |
1250 | ifp->if_flags &= ~IFF_OACTIVE; | 1250 | ifp->if_flags &= ~IFF_OACTIVE; | |
1251 | ipw_start(ifp); /* in softint */ | 1251 | ipw_start(ifp); /* in softint */ | |
1252 | 1252 | |||
1253 | splx(s); | 1253 | splx(s); | |
@@ -1549,47 +1549,47 @@ ipw_start(struct ifnet *ifp) | @@ -1549,47 +1549,47 @@ ipw_start(struct ifnet *ifp) | |||
1549 | 1549 | |||
1550 | bpf_mtap(ifp, m0, BPF_D_OUT); | 1550 | bpf_mtap(ifp, m0, BPF_D_OUT); | |
1551 | 1551 | |||
1552 | m0 = ieee80211_encap(ic, m0, ni); | 1552 | m0 = ieee80211_encap(ic, m0, ni); | |
1553 | if (m0 == NULL) { | 1553 | if (m0 == NULL) { | |
1554 | ieee80211_free_node(ni); | 1554 | ieee80211_free_node(ni); | |
1555 | continue; | 1555 | continue; | |
1556 | } | 1556 | } | |
1557 | 1557 | |||
1558 | bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); | 1558 | bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); | |
1559 | 1559 | |||
1560 | if (ipw_tx_start(ifp, m0, ni) != 0) { | 1560 | if (ipw_tx_start(ifp, m0, ni) != 0) { | |
1561 | ieee80211_free_node(ni); | 1561 | ieee80211_free_node(ni); | |
1562 | ifp->if_oerrors++; | 1562 | if_statinc(ifp, if_oerrors); | |
1563 | break; | 1563 | break; | |
1564 | } | 1564 | } | |
1565 | 1565 | |||
1566 | /* start watchdog timer */ | 1566 | /* start watchdog timer */ | |
1567 | sc->sc_tx_timer = 5; | 1567 | sc->sc_tx_timer = 5; | |
1568 | ifp->if_timer = 1; | 1568 | ifp->if_timer = 1; | |
1569 | } | 1569 | } | |
1570 | } | 1570 | } | |
1571 | 1571 | |||
1572 | static void | 1572 | static void | |
1573 | ipw_watchdog(struct ifnet *ifp) | 1573 | ipw_watchdog(struct ifnet *ifp) | |
1574 | { | 1574 | { | |
1575 | struct ipw_softc *sc = ifp->if_softc; | 1575 | struct ipw_softc *sc = ifp->if_softc; | |
1576 | 1576 | |||
1577 | ifp->if_timer = 0; | 1577 | ifp->if_timer = 0; | |
1578 | 1578 | |||
1579 | if (sc->sc_tx_timer > 0) { | 1579 | if (sc->sc_tx_timer > 0) { | |
1580 | if (--sc->sc_tx_timer == 0) { | 1580 | if (--sc->sc_tx_timer == 0) { | |
1581 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | 1581 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | |
1582 | ifp->if_oerrors++; | 1582 | if_statinc(ifp, if_oerrors); | |
1583 | ifp->if_flags &= ~IFF_UP; | 1583 | ifp->if_flags &= ~IFF_UP; | |
1584 | ipw_stop(ifp, 1); | 1584 | ipw_stop(ifp, 1); | |
1585 | return; | 1585 | return; | |
1586 | } | 1586 | } | |
1587 | ifp->if_timer = 1; | 1587 | ifp->if_timer = 1; | |
1588 | } | 1588 | } | |
1589 | 1589 | |||
1590 | ieee80211_watchdog(&sc->sc_ic); | 1590 | ieee80211_watchdog(&sc->sc_ic); | |
1591 | } | 1591 | } | |
1592 | 1592 | |||
1593 | static int | 1593 | static int | |
1594 | ipw_get_table1(struct ipw_softc *sc, uint32_t *tbl) | 1594 | ipw_get_table1(struct ipw_softc *sc, uint32_t *tbl) | |
1595 | { | 1595 | { |
--- src/sys/dev/pci/if_iwi.c 2019/11/10 21:16:36 1.112
+++ src/sys/dev/pci/if_iwi.c 2020/01/30 06:03:34 1.113
@@ -1,35 +1,35 @@ | @@ -1,35 +1,35 @@ | |||
1 | /* $NetBSD: if_iwi.c,v 1.112 2019/11/10 21:16:36 chs Exp $ */ | 1 | /* $NetBSD: if_iwi.c,v 1.113 2020/01/30 06:03:34 thorpej Exp $ */ | |
2 | /* $OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $ */ | 2 | /* $OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $ */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2004-2008 | 5 | * Copyright (c) 2004-2008 | |
6 | * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. | 6 | * Damien Bergamini <damien.bergamini@free.fr>. All rights reserved. | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify, and distribute this software for any | 8 | * Permission to use, copy, modify, and distribute this software for any | |
9 | * purpose with or without fee is hereby granted, provided that the above | 9 | * purpose with or without fee is hereby granted, provided that the above | |
10 | * copyright notice and this permission notice appear in all copies. | 10 | * copyright notice and this permission notice appear in all copies. | |
11 | * | 11 | * | |
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
19 | */ | 19 | */ | |
20 | 20 | |||
21 | #include <sys/cdefs.h> | 21 | #include <sys/cdefs.h> | |
22 | __KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.112 2019/11/10 21:16:36 chs Exp $"); | 22 | __KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.113 2020/01/30 06:03:34 thorpej Exp $"); | |
23 | 23 | |||
24 | /*- | 24 | /*- | |
25 | * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver | 25 | * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver | |
26 | * http://www.intel.com/network/connectivity/products/wireless/prowireless_mobile.htm | 26 | * http://www.intel.com/network/connectivity/products/wireless/prowireless_mobile.htm | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | 29 | |||
30 | #include <sys/param.h> | 30 | #include <sys/param.h> | |
31 | #include <sys/sockio.h> | 31 | #include <sys/sockio.h> | |
32 | #include <sys/sysctl.h> | 32 | #include <sys/sysctl.h> | |
33 | #include <sys/mbuf.h> | 33 | #include <sys/mbuf.h> | |
34 | #include <sys/kernel.h> | 34 | #include <sys/kernel.h> | |
35 | #include <sys/socket.h> | 35 | #include <sys/socket.h> | |
@@ -1146,54 +1146,54 @@ iwi_frame_intr(struct iwi_softc *sc, str | @@ -1146,54 +1146,54 @@ iwi_frame_intr(struct iwi_softc *sc, str | |||
1146 | struct ieee80211com *ic = &sc->sc_ic; | 1146 | struct ieee80211com *ic = &sc->sc_ic; | |
1147 | struct ifnet *ifp = ic->ic_ifp; | 1147 | struct ifnet *ifp = ic->ic_ifp; | |
1148 | struct mbuf *m, *m_new; | 1148 | struct mbuf *m, *m_new; | |
1149 | struct ieee80211_frame *wh; | 1149 | struct ieee80211_frame *wh; | |
1150 | struct ieee80211_node *ni; | 1150 | struct ieee80211_node *ni; | |
1151 | int error, s; | 1151 | int error, s; | |
1152 | 1152 | |||
1153 | DPRINTFN(5, ("received frame len=%u chan=%u rssi=%u\n", | 1153 | DPRINTFN(5, ("received frame len=%u chan=%u rssi=%u\n", | |
1154 | le16toh(frame->len), frame->chan, frame->rssi_dbm)); | 1154 | le16toh(frame->len), frame->chan, frame->rssi_dbm)); | |
1155 | 1155 | |||
1156 | if (le16toh(frame->len) < sizeof (struct ieee80211_frame) || | 1156 | if (le16toh(frame->len) < sizeof (struct ieee80211_frame) || | |
1157 | le16toh(frame->len) > MCLBYTES) { | 1157 | le16toh(frame->len) > MCLBYTES) { | |
1158 | DPRINTF(("%s: bad frame length\n", device_xname(sc->sc_dev))); | 1158 | DPRINTF(("%s: bad frame length\n", device_xname(sc->sc_dev))); | |
1159 | ifp->if_ierrors++; | 1159 | if_statinc(ifp, if_ierrors); | |
1160 | return; | 1160 | return; | |
1161 | } | 1161 | } | |
1162 | 1162 | |||
1163 | /* | 1163 | /* | |
1164 | * Try to allocate a new mbuf for this ring element and | 1164 | * Try to allocate a new mbuf for this ring element and | |
1165 | * load it before processing the current mbuf. If the ring | 1165 | * load it before processing the current mbuf. If the ring | |
1166 | * element cannot be reloaded, drop the received packet | 1166 | * element cannot be reloaded, drop the received packet | |
1167 | * and reuse the old mbuf. In the unlikely case that | 1167 | * and reuse the old mbuf. In the unlikely case that | |
1168 | * the old mbuf can't be reloaded either, explicitly panic. | 1168 | * the old mbuf can't be reloaded either, explicitly panic. | |
1169 | * | 1169 | * | |
1170 | * XXX Reorganize buffer by moving elements from the logical | 1170 | * XXX Reorganize buffer by moving elements from the logical | |
1171 | * end of the ring to the front instead of dropping. | 1171 | * end of the ring to the front instead of dropping. | |
1172 | */ | 1172 | */ | |
1173 | if ((m_new = iwi_alloc_rx_buf(sc)) == NULL) { | 1173 | if ((m_new = iwi_alloc_rx_buf(sc)) == NULL) { | |
1174 | ifp->if_ierrors++; | 1174 | if_statinc(ifp, if_ierrors); | |
1175 | return; | 1175 | return; | |
1176 | } | 1176 | } | |
1177 | 1177 | |||
1178 | bus_dmamap_unload(sc->sc_dmat, data->map); | 1178 | bus_dmamap_unload(sc->sc_dmat, data->map); | |
1179 | 1179 | |||
1180 | error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m_new, | 1180 | error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, m_new, | |
1181 | BUS_DMA_READ | BUS_DMA_NOWAIT); | 1181 | BUS_DMA_READ | BUS_DMA_NOWAIT); | |
1182 | if (error != 0) { | 1182 | if (error != 0) { | |
1183 | aprint_error_dev(sc->sc_dev, | 1183 | aprint_error_dev(sc->sc_dev, | |
1184 | "could not load rx buf DMA map\n"); | 1184 | "could not load rx buf DMA map\n"); | |
1185 | m_freem(m_new); | 1185 | m_freem(m_new); | |
1186 | ifp->if_ierrors++; | 1186 | if_statinc(ifp, if_ierrors); | |
1187 | error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, | 1187 | error = bus_dmamap_load_mbuf(sc->sc_dmat, data->map, | |
1188 | data->m, BUS_DMA_READ | BUS_DMA_NOWAIT); | 1188 | data->m, BUS_DMA_READ | BUS_DMA_NOWAIT); | |
1189 | if (error) | 1189 | if (error) | |
1190 | panic("%s: unable to remap rx buf", | 1190 | panic("%s: unable to remap rx buf", | |
1191 | device_xname(sc->sc_dev)); | 1191 | device_xname(sc->sc_dev)); | |
1192 | return; | 1192 | return; | |
1193 | } | 1193 | } | |
1194 | 1194 | |||
1195 | /* | 1195 | /* | |
1196 | * New mbuf successfully loaded, update RX ring and continue | 1196 | * New mbuf successfully loaded, update RX ring and continue | |
1197 | * processing. | 1197 | * processing. | |
1198 | */ | 1198 | */ | |
1199 | m = data->m; | 1199 | m = data->m; | |
@@ -1445,27 +1445,27 @@ iwi_tx_intr(struct iwi_softc *sc, struct | @@ -1445,27 +1445,27 @@ iwi_tx_intr(struct iwi_softc *sc, struct | |||
1445 | for (; txq->next != hw;) { | 1445 | for (; txq->next != hw;) { | |
1446 | data = &txq->data[txq->next]; | 1446 | data = &txq->data[txq->next]; | |
1447 | 1447 | |||
1448 | bus_dmamap_sync(sc->sc_dmat, data->map, 0, | 1448 | bus_dmamap_sync(sc->sc_dmat, data->map, 0, | |
1449 | data->map->dm_mapsize, BUS_DMASYNC_POSTWRITE); | 1449 | data->map->dm_mapsize, BUS_DMASYNC_POSTWRITE); | |
1450 | bus_dmamap_unload(sc->sc_dmat, data->map); | 1450 | bus_dmamap_unload(sc->sc_dmat, data->map); | |
1451 | m_freem(data->m); | 1451 | m_freem(data->m); | |
1452 | data->m = NULL; | 1452 | data->m = NULL; | |
1453 | ieee80211_free_node(data->ni); | 1453 | ieee80211_free_node(data->ni); | |
1454 | data->ni = NULL; | 1454 | data->ni = NULL; | |
1455 | 1455 | |||
1456 | DPRINTFN(15, ("tx done idx=%u\n", txq->next)); | 1456 | DPRINTFN(15, ("tx done idx=%u\n", txq->next)); | |
1457 | 1457 | |||
1458 | ifp->if_opackets++; | 1458 | if_statinc(ifp, if_opackets); | |
1459 | 1459 | |||
1460 | txq->queued--; | 1460 | txq->queued--; | |
1461 | txq->next = (txq->next + 1) % txq->count; | 1461 | txq->next = (txq->next + 1) % txq->count; | |
1462 | } | 1462 | } | |
1463 | 1463 | |||
1464 | sc->sc_tx_timer = 0; | 1464 | sc->sc_tx_timer = 0; | |
1465 | 1465 | |||
1466 | if (txq->queued < txq->count - 8 - 8 && (ifp->if_flags & IFF_OACTIVE)) { | 1466 | if (txq->queued < txq->count - 8 - 8 && (ifp->if_flags & IFF_OACTIVE)) { | |
1467 | ifp->if_flags &= ~IFF_OACTIVE; | 1467 | ifp->if_flags &= ~IFF_OACTIVE; | |
1468 | 1468 | |||
1469 | /* Call start() since some buffer descriptors have been released */ | 1469 | /* Call start() since some buffer descriptors have been released */ | |
1470 | iwi_start(ifp); /* in softint */ | 1470 | iwi_start(ifp); /* in softint */ | |
1471 | } | 1471 | } | |
@@ -1619,27 +1619,27 @@ iwi_tx_start(struct ifnet *ifp, struct m | @@ -1619,27 +1619,27 @@ iwi_tx_start(struct ifnet *ifp, struct m | |||
1619 | } else | 1619 | } else | |
1620 | hdrlen = sizeof (struct ieee80211_frame); | 1620 | hdrlen = sizeof (struct ieee80211_frame); | |
1621 | 1621 | |||
1622 | /* | 1622 | /* | |
1623 | * This is only used in IBSS mode where the firmware expect an index | 1623 | * This is only used in IBSS mode where the firmware expect an index | |
1624 | * in a h/w table instead of a destination address. | 1624 | * in a h/w table instead of a destination address. | |
1625 | */ | 1625 | */ | |
1626 | if (ic->ic_opmode == IEEE80211_M_IBSS && in->in_station == -1) { | 1626 | if (ic->ic_opmode == IEEE80211_M_IBSS && in->in_station == -1) { | |
1627 | in->in_station = iwi_alloc_unr(sc); | 1627 | in->in_station = iwi_alloc_unr(sc); | |
1628 | 1628 | |||
1629 | if (in->in_station == -1) { /* h/w table is full */ | 1629 | if (in->in_station == -1) { /* h/w table is full */ | |
1630 | m_freem(m0); | 1630 | m_freem(m0); | |
1631 | ieee80211_free_node(ni); | 1631 | ieee80211_free_node(ni); | |
1632 | ifp->if_oerrors++; | 1632 | if_statinc(ifp, if_oerrors); | |
1633 | return 0; | 1633 | return 0; | |
1634 | } | 1634 | } | |
1635 | iwi_write_ibssnode(sc, in); | 1635 | iwi_write_ibssnode(sc, in); | |
1636 | } | 1636 | } | |
1637 | 1637 | |||
1638 | if (wh->i_fc[1] & IEEE80211_FC1_WEP) { | 1638 | if (wh->i_fc[1] & IEEE80211_FC1_WEP) { | |
1639 | k = ieee80211_crypto_encap(ic, ni, m0); | 1639 | k = ieee80211_crypto_encap(ic, ni, m0); | |
1640 | if (k == NULL) { | 1640 | if (k == NULL) { | |
1641 | m_freem(m0); | 1641 | m_freem(m0); | |
1642 | return ENOBUFS; | 1642 | return ENOBUFS; | |
1643 | } | 1643 | } | |
1644 | 1644 | |||
1645 | /* packet header may have moved, reset our local pointer */ | 1645 | /* packet header may have moved, reset our local pointer */ | |
@@ -1772,93 +1772,93 @@ iwi_start(struct ifnet *ifp) | @@ -1772,93 +1772,93 @@ iwi_start(struct ifnet *ifp) | |||
1772 | struct ieee80211_node *ni; | 1772 | struct ieee80211_node *ni; | |
1773 | int ac; | 1773 | int ac; | |
1774 | 1774 | |||
1775 | if (ic->ic_state != IEEE80211_S_RUN) | 1775 | if (ic->ic_state != IEEE80211_S_RUN) | |
1776 | return; | 1776 | return; | |
1777 | 1777 | |||
1778 | for (;;) { | 1778 | for (;;) { | |
1779 | IFQ_DEQUEUE(&ifp->if_snd, m0); | 1779 | IFQ_DEQUEUE(&ifp->if_snd, m0); | |
1780 | if (m0 == NULL) | 1780 | if (m0 == NULL) | |
1781 | break; | 1781 | break; | |
1782 | 1782 | |||
1783 | if (m0->m_len < sizeof (struct ether_header) && | 1783 | if (m0->m_len < sizeof (struct ether_header) && | |
1784 | (m0 = m_pullup(m0, sizeof (struct ether_header))) == NULL) { | 1784 | (m0 = m_pullup(m0, sizeof (struct ether_header))) == NULL) { | |
1785 | ifp->if_oerrors++; | 1785 | if_statinc(ifp, if_oerrors); | |
1786 | continue; | 1786 | continue; | |
1787 | } | 1787 | } | |
1788 | 1788 | |||
1789 | eh = mtod(m0, struct ether_header *); | 1789 | eh = mtod(m0, struct ether_header *); | |
1790 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | 1790 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | |
1791 | if (ni == NULL) { | 1791 | if (ni == NULL) { | |
1792 | m_freem(m0); | 1792 | m_freem(m0); | |
1793 | ifp->if_oerrors++; | 1793 | if_statinc(ifp, if_oerrors); | |
1794 | continue; | 1794 | continue; | |
1795 | } | 1795 | } | |
1796 | 1796 | |||
1797 | /* classify mbuf so we can find which tx ring to use */ | 1797 | /* classify mbuf so we can find which tx ring to use */ | |
1798 | if (ieee80211_classify(ic, m0, ni) != 0) { | 1798 | if (ieee80211_classify(ic, m0, ni) != 0) { | |
1799 | m_freem(m0); | 1799 | m_freem(m0); | |
1800 | ieee80211_free_node(ni); | 1800 | ieee80211_free_node(ni); | |
1801 | ifp->if_oerrors++; | 1801 | if_statinc(ifp, if_oerrors); | |
1802 | continue; | 1802 | continue; | |
1803 | } | 1803 | } | |
1804 | 1804 | |||
1805 | /* no QoS encapsulation for EAPOL frames */ | 1805 | /* no QoS encapsulation for EAPOL frames */ | |
1806 | ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ? | 1806 | ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ? | |
1807 | M_WME_GETAC(m0) : WME_AC_BE; | 1807 | M_WME_GETAC(m0) : WME_AC_BE; | |
1808 | 1808 | |||
1809 | if (sc->txq[ac].queued > sc->txq[ac].count - 8) { | 1809 | if (sc->txq[ac].queued > sc->txq[ac].count - 8) { | |
1810 | /* there is no place left in this ring */ | 1810 | /* there is no place left in this ring */ | |
1811 | IFQ_LOCK(&ifp->if_snd); | 1811 | IFQ_LOCK(&ifp->if_snd); | |
1812 | IF_PREPEND(&ifp->if_snd, m0); | 1812 | IF_PREPEND(&ifp->if_snd, m0); | |
1813 | IFQ_UNLOCK(&ifp->if_snd); | 1813 | IFQ_UNLOCK(&ifp->if_snd); | |
1814 | ifp->if_flags |= IFF_OACTIVE; | 1814 | ifp->if_flags |= IFF_OACTIVE; | |
1815 | break; | 1815 | break; | |
1816 | } | 1816 | } | |
1817 | 1817 | |||
1818 | bpf_mtap(ifp, m0, BPF_D_OUT); | 1818 | bpf_mtap(ifp, m0, BPF_D_OUT); | |
1819 | 1819 | |||
1820 | m0 = ieee80211_encap(ic, m0, ni); | 1820 | m0 = ieee80211_encap(ic, m0, ni); | |
1821 | if (m0 == NULL) { | 1821 | if (m0 == NULL) { | |
1822 | ieee80211_free_node(ni); | 1822 | ieee80211_free_node(ni); | |
1823 | ifp->if_oerrors++; | 1823 | if_statinc(ifp, if_oerrors); | |
1824 | continue; | 1824 | continue; | |
1825 | } | 1825 | } | |
1826 | 1826 | |||
1827 | bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); | 1827 | bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); | |
1828 | 1828 | |||
1829 | if (iwi_tx_start(ifp, m0, ni, ac) != 0) { | 1829 | if (iwi_tx_start(ifp, m0, ni, ac) != 0) { | |
1830 | ieee80211_free_node(ni); | 1830 | ieee80211_free_node(ni); | |
1831 | ifp->if_oerrors++; | 1831 | if_statinc(ifp, if_oerrors); | |
1832 | break; | 1832 | break; | |
1833 | } | 1833 | } | |
1834 | 1834 | |||
1835 | /* start watchdog timer */ | 1835 | /* start watchdog timer */ | |
1836 | sc->sc_tx_timer = 5; | 1836 | sc->sc_tx_timer = 5; | |
1837 | ifp->if_timer = 1; | 1837 | ifp->if_timer = 1; | |
1838 | } | 1838 | } | |
1839 | } | 1839 | } | |
1840 | 1840 | |||
1841 | static void | 1841 | static void | |
1842 | iwi_watchdog(struct ifnet *ifp) | 1842 | iwi_watchdog(struct ifnet *ifp) | |
1843 | { | 1843 | { | |
1844 | struct iwi_softc *sc = ifp->if_softc; | 1844 | struct iwi_softc *sc = ifp->if_softc; | |
1845 | 1845 | |||
1846 | ifp->if_timer = 0; | 1846 | ifp->if_timer = 0; | |
1847 | 1847 | |||
1848 | if (sc->sc_tx_timer > 0) { | 1848 | if (sc->sc_tx_timer > 0) { | |
1849 | if (--sc->sc_tx_timer == 0) { | 1849 | if (--sc->sc_tx_timer == 0) { | |
1850 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | 1850 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | |
1851 | ifp->if_oerrors++; | 1851 | if_statinc(ifp, if_oerrors); | |
1852 | ifp->if_flags &= ~IFF_UP; | 1852 | ifp->if_flags &= ~IFF_UP; | |
1853 | iwi_stop(ifp, 1); | 1853 | iwi_stop(ifp, 1); | |
1854 | return; | 1854 | return; | |
1855 | } | 1855 | } | |
1856 | ifp->if_timer = 1; | 1856 | ifp->if_timer = 1; | |
1857 | } | 1857 | } | |
1858 | 1858 | |||
1859 | ieee80211_watchdog(&sc->sc_ic); | 1859 | ieee80211_watchdog(&sc->sc_ic); | |
1860 | } | 1860 | } | |
1861 | 1861 | |||
1862 | static int | 1862 | static int | |
1863 | iwi_get_table0(struct iwi_softc *sc, uint32_t *tbl) | 1863 | iwi_get_table0(struct iwi_softc *sc, uint32_t *tbl) | |
1864 | { | 1864 | { |
--- src/sys/dev/pci/if_iwm.c 2018/06/26 06:48:01 1.83
+++ src/sys/dev/pci/if_iwm.c 2020/01/30 06:03:34 1.84
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_iwm.c,v 1.83 2018/06/26 06:48:01 msaitoh Exp $ */ | 1 | /* $NetBSD: if_iwm.c,v 1.84 2020/01/30 06:03:34 thorpej Exp $ */ | |
2 | /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ | 2 | /* OpenBSD: if_iwm.c,v 1.148 2016/11/19 21:07:08 stsp Exp */ | |
3 | #define IEEE80211_NO_HT | 3 | #define IEEE80211_NO_HT | |
4 | /* | 4 | /* | |
5 | * Copyright (c) 2014, 2016 genua gmbh <info@genua.de> | 5 | * Copyright (c) 2014, 2016 genua gmbh <info@genua.de> | |
6 | * Author: Stefan Sperling <stsp@openbsd.org> | 6 | * Author: Stefan Sperling <stsp@openbsd.org> | |
7 | * Copyright (c) 2014 Fixup Software Ltd. | 7 | * Copyright (c) 2014 Fixup Software Ltd. | |
8 | * | 8 | * | |
9 | * Permission to use, copy, modify, and distribute this software for any | 9 | * Permission to use, copy, modify, and distribute this software for any | |
10 | * purpose with or without fee is hereby granted, provided that the above | 10 | * purpose with or without fee is hereby granted, provided that the above | |
11 | * copyright notice and this permission notice appear in all copies. | 11 | * copyright notice and this permission notice appear in all copies. | |
12 | * | 12 | * | |
13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 13 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 14 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
@@ -96,27 +96,27 @@ | @@ -96,27 +96,27 @@ | |||
96 | * purpose with or without fee is hereby granted, provided that the above | 96 | * purpose with or without fee is hereby granted, provided that the above | |
97 | * copyright notice and this permission notice appear in all copies. | 97 | * copyright notice and this permission notice appear in all copies. | |
98 | * | 98 | * | |
99 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 99 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
100 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 100 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
101 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 101 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
102 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 102 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
103 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 103 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
104 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 104 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
105 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 105 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
106 | */ | 106 | */ | |
107 | 107 | |||
108 | #include <sys/cdefs.h> | 108 | #include <sys/cdefs.h> | |
109 | __KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.83 2018/06/26 06:48:01 msaitoh Exp $"); | 109 | __KERNEL_RCSID(0, "$NetBSD: if_iwm.c,v 1.84 2020/01/30 06:03:34 thorpej Exp $"); | |
110 | 110 | |||
111 | #include <sys/param.h> | 111 | #include <sys/param.h> | |
112 | #include <sys/conf.h> | 112 | #include <sys/conf.h> | |
113 | #include <sys/kernel.h> | 113 | #include <sys/kernel.h> | |
114 | #include <sys/kmem.h> | 114 | #include <sys/kmem.h> | |
115 | #include <sys/mbuf.h> | 115 | #include <sys/mbuf.h> | |
116 | #include <sys/mutex.h> | 116 | #include <sys/mutex.h> | |
117 | #include <sys/proc.h> | 117 | #include <sys/proc.h> | |
118 | #include <sys/socket.h> | 118 | #include <sys/socket.h> | |
119 | #include <sys/sockio.h> | 119 | #include <sys/sockio.h> | |
120 | #include <sys/sysctl.h> | 120 | #include <sys/sysctl.h> | |
121 | #include <sys/systm.h> | 121 | #include <sys/systm.h> | |
122 | 122 | |||
@@ -4021,29 +4021,29 @@ iwm_rx_tx_cmd_single(struct iwm_softc *s | @@ -4021,29 +4021,29 @@ iwm_rx_tx_cmd_single(struct iwm_softc *s | |||
4021 | int status = le16toh(tx_resp->status.status) & IWM_TX_STATUS_MSK; | 4021 | int status = le16toh(tx_resp->status.status) & IWM_TX_STATUS_MSK; | |
4022 | int failack = tx_resp->failure_frame; | 4022 | int failack = tx_resp->failure_frame; | |
4023 | 4023 | |||
4024 | KASSERT(tx_resp->frame_count == 1); | 4024 | KASSERT(tx_resp->frame_count == 1); | |
4025 | 4025 | |||
4026 | /* Update rate control statistics. */ | 4026 | /* Update rate control statistics. */ | |
4027 | in->in_amn.amn_txcnt++; | 4027 | in->in_amn.amn_txcnt++; | |
4028 | if (failack > 0) { | 4028 | if (failack > 0) { | |
4029 | in->in_amn.amn_retrycnt++; | 4029 | in->in_amn.amn_retrycnt++; | |
4030 | } | 4030 | } | |
4031 | 4031 | |||
4032 | if (status != IWM_TX_STATUS_SUCCESS && | 4032 | if (status != IWM_TX_STATUS_SUCCESS && | |
4033 | status != IWM_TX_STATUS_DIRECT_DONE) | 4033 | status != IWM_TX_STATUS_DIRECT_DONE) | |
4034 | ifp->if_oerrors++; | 4034 | if_statinc(ifp, if_oerrors); | |
4035 | else | 4035 | else | |
4036 | ifp->if_opackets++; | 4036 | if_statinc(ifp, if_opackets); | |
4037 | } | 4037 | } | |
4038 | 4038 | |||
4039 | static void | 4039 | static void | |
4040 | iwm_rx_tx_cmd(struct iwm_softc *sc, struct iwm_rx_packet *pkt, | 4040 | iwm_rx_tx_cmd(struct iwm_softc *sc, struct iwm_rx_packet *pkt, | |
4041 | struct iwm_rx_data *data) | 4041 | struct iwm_rx_data *data) | |
4042 | { | 4042 | { | |
4043 | struct ieee80211com *ic = &sc->sc_ic; | 4043 | struct ieee80211com *ic = &sc->sc_ic; | |
4044 | struct ifnet *ifp = IC2IFP(ic); | 4044 | struct ifnet *ifp = IC2IFP(ic); | |
4045 | struct iwm_cmd_header *cmd_hdr = &pkt->hdr; | 4045 | struct iwm_cmd_header *cmd_hdr = &pkt->hdr; | |
4046 | int idx = cmd_hdr->idx; | 4046 | int idx = cmd_hdr->idx; | |
4047 | int qid = cmd_hdr->qid; | 4047 | int qid = cmd_hdr->qid; | |
4048 | struct iwm_tx_ring *ring = &sc->txq[qid]; | 4048 | struct iwm_tx_ring *ring = &sc->txq[qid]; | |
4049 | struct iwm_tx_data *txd = &ring->data[idx]; | 4049 | struct iwm_tx_data *txd = &ring->data[idx]; | |
@@ -6814,64 +6814,64 @@ iwm_start(struct ifnet *ifp) | @@ -6814,64 +6814,64 @@ iwm_start(struct ifnet *ifp) | |||
6814 | ac = WME_AC_BE; | 6814 | ac = WME_AC_BE; | |
6815 | goto sendit; | 6815 | goto sendit; | |
6816 | } | 6816 | } | |
6817 | if (ic->ic_state != IEEE80211_S_RUN) { | 6817 | if (ic->ic_state != IEEE80211_S_RUN) { | |
6818 | break; | 6818 | break; | |
6819 | } | 6819 | } | |
6820 | 6820 | |||
6821 | IFQ_DEQUEUE(&ifp->if_snd, m); | 6821 | IFQ_DEQUEUE(&ifp->if_snd, m); | |
6822 | if (m == NULL) | 6822 | if (m == NULL) | |
6823 | break; | 6823 | break; | |
6824 | 6824 | |||
6825 | if (m->m_len < sizeof (*eh) && | 6825 | if (m->m_len < sizeof (*eh) && | |
6826 | (m = m_pullup(m, sizeof (*eh))) == NULL) { | 6826 | (m = m_pullup(m, sizeof (*eh))) == NULL) { | |
6827 | ifp->if_oerrors++; | 6827 | if_statinc(ifp, if_oerrors); | |
6828 | continue; | 6828 | continue; | |
6829 | } | 6829 | } | |
6830 | 6830 | |||
6831 | eh = mtod(m, struct ether_header *); | 6831 | eh = mtod(m, struct ether_header *); | |
6832 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | 6832 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | |
6833 | if (ni == NULL) { | 6833 | if (ni == NULL) { | |
6834 | m_freem(m); | 6834 | m_freem(m); | |
6835 | ifp->if_oerrors++; | 6835 | if_statinc(ifp, if_oerrors); | |
6836 | continue; | 6836 | continue; | |
6837 | } | 6837 | } | |
6838 | 6838 | |||
6839 | /* classify mbuf so we can find which tx ring to use */ | 6839 | /* classify mbuf so we can find which tx ring to use */ | |
6840 | if (ieee80211_classify(ic, m, ni) != 0) { | 6840 | if (ieee80211_classify(ic, m, ni) != 0) { | |
6841 | m_freem(m); | 6841 | m_freem(m); | |
6842 | ieee80211_free_node(ni); | 6842 | ieee80211_free_node(ni); | |
6843 | ifp->if_oerrors++; | 6843 | if_statinc(ifp, if_oerrors); | |
6844 | continue; | 6844 | continue; | |
6845 | } | 6845 | } | |
6846 | 6846 | |||
6847 | /* No QoS encapsulation for EAPOL frames. */ | 6847 | /* No QoS encapsulation for EAPOL frames. */ | |
6848 | ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ? | 6848 | ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ? | |
6849 | M_WME_GETAC(m) : WME_AC_BE; | 6849 | M_WME_GETAC(m) : WME_AC_BE; | |
6850 | 6850 | |||
6851 | bpf_mtap(ifp, m, BPF_D_OUT); | 6851 | bpf_mtap(ifp, m, BPF_D_OUT); | |
6852 | 6852 | |||
6853 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) { | 6853 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) { | |
6854 | ieee80211_free_node(ni); | 6854 | ieee80211_free_node(ni); | |
6855 | ifp->if_oerrors++; | 6855 | if_statinc(ifp, if_oerrors); | |
6856 | continue; | 6856 | continue; | |
6857 | } | 6857 | } | |
6858 | 6858 | |||
6859 | sendit: | 6859 | sendit: | |
6860 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | 6860 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | |
6861 | 6861 | |||
6862 | if (iwm_tx(sc, m, ni, ac) != 0) { | 6862 | if (iwm_tx(sc, m, ni, ac) != 0) { | |
6863 | ieee80211_free_node(ni); | 6863 | ieee80211_free_node(ni); | |
6864 | ifp->if_oerrors++; | 6864 | if_statinc(ifp, if_oerrors); | |
6865 | continue; | 6865 | continue; | |
6866 | } | 6866 | } | |
6867 | 6867 | |||
6868 | if (ifp->if_flags & IFF_UP) { | 6868 | if (ifp->if_flags & IFF_UP) { | |
6869 | sc->sc_tx_timer = 15; | 6869 | sc->sc_tx_timer = 15; | |
6870 | ifp->if_timer = 1; | 6870 | ifp->if_timer = 1; | |
6871 | } | 6871 | } | |
6872 | } | 6872 | } | |
6873 | } | 6873 | } | |
6874 | 6874 | |||
6875 | static void | 6875 | static void | |
6876 | iwm_stop(struct ifnet *ifp, int disable) | 6876 | iwm_stop(struct ifnet *ifp, int disable) | |
6877 | { | 6877 | { | |
@@ -6900,27 +6900,27 @@ static void | @@ -6900,27 +6900,27 @@ static void | |||
6900 | iwm_watchdog(struct ifnet *ifp) | 6900 | iwm_watchdog(struct ifnet *ifp) | |
6901 | { | 6901 | { | |
6902 | struct iwm_softc *sc = ifp->if_softc; | 6902 | struct iwm_softc *sc = ifp->if_softc; | |
6903 | 6903 | |||
6904 | ifp->if_timer = 0; | 6904 | ifp->if_timer = 0; | |
6905 | if (sc->sc_tx_timer > 0) { | 6905 | if (sc->sc_tx_timer > 0) { | |
6906 | if (--sc->sc_tx_timer == 0) { | 6906 | if (--sc->sc_tx_timer == 0) { | |
6907 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | 6907 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | |
6908 | #ifdef IWM_DEBUG | 6908 | #ifdef IWM_DEBUG | |
6909 | iwm_nic_error(sc); | 6909 | iwm_nic_error(sc); | |
6910 | #endif | 6910 | #endif | |
6911 | ifp->if_flags &= ~IFF_UP; | 6911 | ifp->if_flags &= ~IFF_UP; | |
6912 | iwm_stop(ifp, 1); | 6912 | iwm_stop(ifp, 1); | |
6913 | ifp->if_oerrors++; | 6913 | if_statinc(ifp, if_oerrors); | |
6914 | return; | 6914 | return; | |
6915 | } | 6915 | } | |
6916 | ifp->if_timer = 1; | 6916 | ifp->if_timer = 1; | |
6917 | } | 6917 | } | |
6918 | 6918 | |||
6919 | ieee80211_watchdog(&sc->sc_ic); | 6919 | ieee80211_watchdog(&sc->sc_ic); | |
6920 | } | 6920 | } | |
6921 | 6921 | |||
6922 | static int | 6922 | static int | |
6923 | iwm_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 6923 | iwm_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
6924 | { | 6924 | { | |
6925 | struct iwm_softc *sc = ifp->if_softc; | 6925 | struct iwm_softc *sc = ifp->if_softc; | |
6926 | struct ieee80211com *ic = &sc->sc_ic; | 6926 | struct ieee80211com *ic = &sc->sc_ic; |
--- src/sys/dev/pci/if_iwn.c 2019/10/10 22:34:42 1.92
+++ src/sys/dev/pci/if_iwn.c 2020/01/30 06:03:34 1.93
@@ -1,38 +1,38 @@ | @@ -1,38 +1,38 @@ | |||
1 | /* $NetBSD: if_iwn.c,v 1.92 2019/10/10 22:34:42 bad Exp $ */ | 1 | /* $NetBSD: if_iwn.c,v 1.93 2020/01/30 06:03:34 thorpej Exp $ */ | |
2 | /* $OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $ */ | 2 | /* $OpenBSD: if_iwn.c,v 1.135 2014/09/10 07:22:09 dcoppa Exp $ */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr> | 5 | * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr> | |
6 | * | 6 | * | |
7 | * Permission to use, copy, modify, and distribute this software for any | 7 | * Permission to use, copy, modify, and distribute this software for any | |
8 | * purpose with or without fee is hereby granted, provided that the above | 8 | * purpose with or without fee is hereby granted, provided that the above | |
9 | * copyright notice and this permission notice appear in all copies. | 9 | * copyright notice and this permission notice appear in all copies. | |
10 | * | 10 | * | |
11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 12 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 13 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 14 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 15 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 16 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 17 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
18 | */ | 18 | */ | |
19 | 19 | |||
20 | /* | 20 | /* | |
21 | * Driver for Intel WiFi Link 4965 and 1000/5000/6000 Series 802.11 network | 21 | * Driver for Intel WiFi Link 4965 and 1000/5000/6000 Series 802.11 network | |
22 | * adapters. | 22 | * adapters. | |
23 | */ | 23 | */ | |
24 | #include <sys/cdefs.h> | 24 | #include <sys/cdefs.h> | |
25 | __KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.92 2019/10/10 22:34:42 bad Exp $"); | 25 | __KERNEL_RCSID(0, "$NetBSD: if_iwn.c,v 1.93 2020/01/30 06:03:34 thorpej Exp $"); | |
26 | 26 | |||
27 | #define IWN_USE_RBUF /* Use local storage for RX */ | 27 | #define IWN_USE_RBUF /* Use local storage for RX */ | |
28 | #undef IWN_HWCRYPTO /* XXX does not even compile yet */ | 28 | #undef IWN_HWCRYPTO /* XXX does not even compile yet */ | |
29 | 29 | |||
30 | #include <sys/param.h> | 30 | #include <sys/param.h> | |
31 | #include <sys/sockio.h> | 31 | #include <sys/sockio.h> | |
32 | #include <sys/proc.h> | 32 | #include <sys/proc.h> | |
33 | #include <sys/mbuf.h> | 33 | #include <sys/mbuf.h> | |
34 | #include <sys/kernel.h> | 34 | #include <sys/kernel.h> | |
35 | #include <sys/socket.h> | 35 | #include <sys/socket.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | #include <sys/malloc.h> | 37 | #include <sys/malloc.h> | |
38 | #ifdef notyetMODULE | 38 | #ifdef notyetMODULE | |
@@ -2065,65 +2065,65 @@ iwn_rx_done(struct iwn_softc *sc, struct | @@ -2065,65 +2065,65 @@ iwn_rx_done(struct iwn_softc *sc, struct | |||
2065 | struct iwn_rx_mpdu *mpdu = (struct iwn_rx_mpdu *)(desc + 1); | 2065 | struct iwn_rx_mpdu *mpdu = (struct iwn_rx_mpdu *)(desc + 1); | |
2066 | head = (char *)(mpdu + 1); | 2066 | head = (char *)(mpdu + 1); | |
2067 | len = le16toh(mpdu->len); | 2067 | len = le16toh(mpdu->len); | |
2068 | } else { | 2068 | } else { | |
2069 | head = (char *)(stat + 1) + stat->cfg_phy_len; | 2069 | head = (char *)(stat + 1) + stat->cfg_phy_len; | |
2070 | len = le16toh(stat->len); | 2070 | len = le16toh(stat->len); | |
2071 | } | 2071 | } | |
2072 | 2072 | |||
2073 | flags = le32toh(*(uint32_t *)(head + len)); | 2073 | flags = le32toh(*(uint32_t *)(head + len)); | |
2074 | 2074 | |||
2075 | /* Discard frames with a bad FCS early. */ | 2075 | /* Discard frames with a bad FCS early. */ | |
2076 | if ((flags & IWN_RX_NOERROR) != IWN_RX_NOERROR) { | 2076 | if ((flags & IWN_RX_NOERROR) != IWN_RX_NOERROR) { | |
2077 | DPRINTFN(2, ("RX flags error %x\n", flags)); | 2077 | DPRINTFN(2, ("RX flags error %x\n", flags)); | |
2078 | ifp->if_ierrors++; | 2078 | if_statinc(ifp, if_ierrors); | |
2079 | return; | 2079 | return; | |
2080 | } | 2080 | } | |
2081 | /* Discard frames that are too short. */ | 2081 | /* Discard frames that are too short. */ | |
2082 | if (len < sizeof (*wh)) { | 2082 | if (len < sizeof (*wh)) { | |
2083 | DPRINTF(("frame too short: %d\n", len)); | 2083 | DPRINTF(("frame too short: %d\n", len)); | |
2084 | ic->ic_stats.is_rx_tooshort++; | 2084 | ic->ic_stats.is_rx_tooshort++; | |
2085 | ifp->if_ierrors++; | 2085 | if_statinc(ifp, if_ierrors); | |
2086 | return; | 2086 | return; | |
2087 | } | 2087 | } | |
2088 | 2088 | |||
2089 | m1 = MCLGETIalt(sc, M_DONTWAIT, NULL, IWN_RBUF_SIZE); | 2089 | m1 = MCLGETIalt(sc, M_DONTWAIT, NULL, IWN_RBUF_SIZE); | |
2090 | if (m1 == NULL) { | 2090 | if (m1 == NULL) { | |
2091 | ic->ic_stats.is_rx_nobuf++; | 2091 | ic->ic_stats.is_rx_nobuf++; | |
2092 | ifp->if_ierrors++; | 2092 | if_statinc(ifp, if_ierrors); | |
2093 | return; | 2093 | return; | |
2094 | } | 2094 | } | |
2095 | bus_dmamap_unload(sc->sc_dmat, data->map); | 2095 | bus_dmamap_unload(sc->sc_dmat, data->map); | |
2096 | 2096 | |||
2097 | error = bus_dmamap_load(sc->sc_dmat, data->map, mtod(m1, void *), | 2097 | error = bus_dmamap_load(sc->sc_dmat, data->map, mtod(m1, void *), | |
2098 | IWN_RBUF_SIZE, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | 2098 | IWN_RBUF_SIZE, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | |
2099 | if (error != 0) { | 2099 | if (error != 0) { | |
2100 | m_freem(m1); | 2100 | m_freem(m1); | |
2101 | 2101 | |||
2102 | /* Try to reload the old mbuf. */ | 2102 | /* Try to reload the old mbuf. */ | |
2103 | error = bus_dmamap_load(sc->sc_dmat, data->map, | 2103 | error = bus_dmamap_load(sc->sc_dmat, data->map, | |
2104 | mtod(data->m, void *), IWN_RBUF_SIZE, NULL, | 2104 | mtod(data->m, void *), IWN_RBUF_SIZE, NULL, | |
2105 | BUS_DMA_NOWAIT | BUS_DMA_READ); | 2105 | BUS_DMA_NOWAIT | BUS_DMA_READ); | |
2106 | if (error != 0) { | 2106 | if (error != 0) { | |
2107 | panic("%s: could not load old RX mbuf", | 2107 | panic("%s: could not load old RX mbuf", | |
2108 | device_xname(sc->sc_dev)); | 2108 | device_xname(sc->sc_dev)); | |
2109 | } | 2109 | } | |
2110 | /* Physical address may have changed. */ | 2110 | /* Physical address may have changed. */ | |
2111 | ring->desc[ring->cur] = | 2111 | ring->desc[ring->cur] = | |
2112 | htole32(data->map->dm_segs[0].ds_addr >> 8); | 2112 | htole32(data->map->dm_segs[0].ds_addr >> 8); | |
2113 | bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, | 2113 | bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, | |
2114 | ring->cur * sizeof (uint32_t), sizeof (uint32_t), | 2114 | ring->cur * sizeof (uint32_t), sizeof (uint32_t), | |
2115 | BUS_DMASYNC_PREWRITE); | 2115 | BUS_DMASYNC_PREWRITE); | |
2116 | ifp->if_ierrors++; | 2116 | if_statinc(ifp, if_ierrors); | |
2117 | return; | 2117 | return; | |
2118 | } | 2118 | } | |
2119 | 2119 | |||
2120 | m = data->m; | 2120 | m = data->m; | |
2121 | data->m = m1; | 2121 | data->m = m1; | |
2122 | /* Update RX descriptor. */ | 2122 | /* Update RX descriptor. */ | |
2123 | ring->desc[ring->cur] = htole32(data->map->dm_segs[0].ds_addr >> 8); | 2123 | ring->desc[ring->cur] = htole32(data->map->dm_segs[0].ds_addr >> 8); | |
2124 | bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, | 2124 | bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, | |
2125 | ring->cur * sizeof (uint32_t), sizeof (uint32_t), | 2125 | ring->cur * sizeof (uint32_t), sizeof (uint32_t), | |
2126 | BUS_DMASYNC_PREWRITE); | 2126 | BUS_DMASYNC_PREWRITE); | |
2127 | 2127 | |||
2128 | /* Finalize mbuf. */ | 2128 | /* Finalize mbuf. */ | |
2129 | m_set_rcvif(m, ifp); | 2129 | m_set_rcvif(m, ifp); | |
@@ -2390,29 +2390,29 @@ iwn_tx_done(struct iwn_softc *sc, struct | @@ -2390,29 +2390,29 @@ iwn_tx_done(struct iwn_softc *sc, struct | |||
2390 | struct iwn_tx_ring *ring = &sc->txq[desc->qid & 0xf]; | 2390 | struct iwn_tx_ring *ring = &sc->txq[desc->qid & 0xf]; | |
2391 | struct iwn_tx_data *data = &ring->data[desc->idx]; | 2391 | struct iwn_tx_data *data = &ring->data[desc->idx]; | |
2392 | struct iwn_node *wn = (struct iwn_node *)data->ni; | 2392 | struct iwn_node *wn = (struct iwn_node *)data->ni; | |
2393 | int s; | 2393 | int s; | |
2394 | 2394 | |||
2395 | s = splnet(); | 2395 | s = splnet(); | |
2396 | 2396 | |||
2397 | /* Update rate control statistics. */ | 2397 | /* Update rate control statistics. */ | |
2398 | wn->amn.amn_txcnt++; | 2398 | wn->amn.amn_txcnt++; | |
2399 | if (ackfailcnt > 0) | 2399 | if (ackfailcnt > 0) | |
2400 | wn->amn.amn_retrycnt++; | 2400 | wn->amn.amn_retrycnt++; | |
2401 | 2401 | |||
2402 | if (status != 1 && status != 2) | 2402 | if (status != 1 && status != 2) | |
2403 | ifp->if_oerrors++; | 2403 | if_statinc(ifp, if_oerrors); | |
2404 | else | 2404 | else | |
2405 | ifp->if_opackets++; | 2405 | if_statinc(ifp, if_opackets); | |
2406 | 2406 | |||
2407 | /* Unmap and free mbuf. */ | 2407 | /* Unmap and free mbuf. */ | |
2408 | bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize, | 2408 | bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize, | |
2409 | BUS_DMASYNC_POSTWRITE); | 2409 | BUS_DMASYNC_POSTWRITE); | |
2410 | bus_dmamap_unload(sc->sc_dmat, data->map); | 2410 | bus_dmamap_unload(sc->sc_dmat, data->map); | |
2411 | m_freem(data->m); | 2411 | m_freem(data->m); | |
2412 | data->m = NULL; | 2412 | data->m = NULL; | |
2413 | ieee80211_free_node(data->ni); | 2413 | ieee80211_free_node(data->ni); | |
2414 | data->ni = NULL; | 2414 | data->ni = NULL; | |
2415 | 2415 | |||
2416 | sc->sc_tx_timer = 0; | 2416 | sc->sc_tx_timer = 0; | |
2417 | if (--ring->queued < IWN_TX_RING_LOMARK) { | 2417 | if (--ring->queued < IWN_TX_RING_LOMARK) { | |
2418 | sc->qfullmsk &= ~(1 << ring->qid); | 2418 | sc->qfullmsk &= ~(1 << ring->qid); | |
@@ -3202,90 +3202,90 @@ iwn_start(struct ifnet *ifp) | @@ -3202,90 +3202,90 @@ iwn_start(struct ifnet *ifp) | |||
3202 | ni = M_GETCTX(m, struct ieee80211_node *); | 3202 | ni = M_GETCTX(m, struct ieee80211_node *); | |
3203 | ac = 0; | 3203 | ac = 0; | |
3204 | goto sendit; | 3204 | goto sendit; | |
3205 | } | 3205 | } | |
3206 | if (ic->ic_state != IEEE80211_S_RUN) | 3206 | if (ic->ic_state != IEEE80211_S_RUN) | |
3207 | break; | 3207 | break; | |
3208 | 3208 | |||
3209 | /* Encapsulate and send data frames. */ | 3209 | /* Encapsulate and send data frames. */ | |
3210 | IFQ_DEQUEUE(&ifp->if_snd, m); | 3210 | IFQ_DEQUEUE(&ifp->if_snd, m); | |
3211 | if (m == NULL) | 3211 | if (m == NULL) | |
3212 | break; | 3212 | break; | |
3213 | if (m->m_len < sizeof (*eh) && | 3213 | if (m->m_len < sizeof (*eh) && | |
3214 | (m = m_pullup(m, sizeof (*eh))) == NULL) { | 3214 | (m = m_pullup(m, sizeof (*eh))) == NULL) { | |
3215 | ifp->if_oerrors++; | 3215 | if_statinc(ifp, if_oerrors); | |
3216 | continue; | 3216 | continue; | |
3217 | } | 3217 | } | |
3218 | eh = mtod(m, struct ether_header *); | 3218 | eh = mtod(m, struct ether_header *); | |
3219 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | 3219 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | |
3220 | if (ni == NULL) { | 3220 | if (ni == NULL) { | |
3221 | m_freem(m); | 3221 | m_freem(m); | |
3222 | ifp->if_oerrors++; | 3222 | if_statinc(ifp, if_oerrors); | |
3223 | continue; | 3223 | continue; | |
3224 | } | 3224 | } | |
3225 | /* classify mbuf so we can find which tx ring to use */ | 3225 | /* classify mbuf so we can find which tx ring to use */ | |
3226 | if (ieee80211_classify(ic, m, ni) != 0) { | 3226 | if (ieee80211_classify(ic, m, ni) != 0) { | |
3227 | m_freem(m); | 3227 | m_freem(m); | |
3228 | ieee80211_free_node(ni); | 3228 | ieee80211_free_node(ni); | |
3229 | ifp->if_oerrors++; | 3229 | if_statinc(ifp, if_oerrors); | |
3230 | continue; | 3230 | continue; | |
3231 | } | 3231 | } | |
3232 | 3232 | |||
3233 | /* No QoS encapsulation for EAPOL frames. */ | 3233 | /* No QoS encapsulation for EAPOL frames. */ | |
3234 | ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ? | 3234 | ac = (eh->ether_type != htons(ETHERTYPE_PAE)) ? | |
3235 | M_WME_GETAC(m) : WME_AC_BE; | 3235 | M_WME_GETAC(m) : WME_AC_BE; | |
3236 | 3236 | |||
3237 | if (sc->sc_beacon_wait == 0) | 3237 | if (sc->sc_beacon_wait == 0) | |
3238 | bpf_mtap(ifp, m, BPF_D_OUT); | 3238 | bpf_mtap(ifp, m, BPF_D_OUT); | |
3239 | 3239 | |||
3240 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) { | 3240 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) { | |
3241 | ieee80211_free_node(ni); | 3241 | ieee80211_free_node(ni); | |
3242 | ifp->if_oerrors++; | 3242 | if_statinc(ifp, if_oerrors); | |
3243 | continue; | 3243 | continue; | |
3244 | } | 3244 | } | |
3245 | sendit: | 3245 | sendit: | |
3246 | if (sc->sc_beacon_wait) | 3246 | if (sc->sc_beacon_wait) | |
3247 | continue; | 3247 | continue; | |
3248 | 3248 | |||
3249 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | 3249 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | |
3250 | 3250 | |||
3251 | if (iwn_tx(sc, m, ni, ac) != 0) { | 3251 | if (iwn_tx(sc, m, ni, ac) != 0) { | |
3252 | ieee80211_free_node(ni); | 3252 | ieee80211_free_node(ni); | |
3253 | ifp->if_oerrors++; | 3253 | if_statinc(ifp, if_oerrors); | |
3254 | continue; | 3254 | continue; | |
3255 | } | 3255 | } | |
3256 | 3256 | |||
3257 | sc->sc_tx_timer = 5; | 3257 | sc->sc_tx_timer = 5; | |
3258 | ifp->if_timer = 1; | 3258 | ifp->if_timer = 1; | |
3259 | } | 3259 | } | |
3260 | 3260 | |||
3261 | if (sc->sc_beacon_wait > 1) | 3261 | if (sc->sc_beacon_wait > 1) | |
3262 | sc->sc_beacon_wait = 0; | 3262 | sc->sc_beacon_wait = 0; | |
3263 | } | 3263 | } | |
3264 | 3264 | |||
3265 | static void | 3265 | static void | |
3266 | iwn_watchdog(struct ifnet *ifp) | 3266 | iwn_watchdog(struct ifnet *ifp) | |
3267 | { | 3267 | { | |
3268 | struct iwn_softc *sc = ifp->if_softc; | 3268 | struct iwn_softc *sc = ifp->if_softc; | |
3269 | 3269 | |||
3270 | ifp->if_timer = 0; | 3270 | ifp->if_timer = 0; | |
3271 | 3271 | |||
3272 | if (sc->sc_tx_timer > 0) { | 3272 | if (sc->sc_tx_timer > 0) { | |
3273 | if (--sc->sc_tx_timer == 0) { | 3273 | if (--sc->sc_tx_timer == 0) { | |
3274 | aprint_error_dev(sc->sc_dev, | 3274 | aprint_error_dev(sc->sc_dev, | |
3275 | "device timeout\n"); | 3275 | "device timeout\n"); | |
3276 | ifp->if_flags &= ~IFF_UP; | 3276 | ifp->if_flags &= ~IFF_UP; | |
3277 | iwn_stop(ifp, 1); | 3277 | iwn_stop(ifp, 1); | |
3278 | ifp->if_oerrors++; | 3278 | if_statinc(ifp, if_oerrors); | |
3279 | return; | 3279 | return; | |
3280 | } | 3280 | } | |
3281 | ifp->if_timer = 1; | 3281 | ifp->if_timer = 1; | |
3282 | } | 3282 | } | |
3283 | 3283 | |||
3284 | ieee80211_watchdog(&sc->sc_ic); | 3284 | ieee80211_watchdog(&sc->sc_ic); | |
3285 | } | 3285 | } | |
3286 | 3286 | |||
3287 | static int | 3287 | static int | |
3288 | iwn_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 3288 | iwn_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
3289 | { | 3289 | { | |
3290 | struct iwn_softc *sc = ifp->if_softc; | 3290 | struct iwn_softc *sc = ifp->if_softc; | |
3291 | struct ieee80211com *ic = &sc->sc_ic; | 3291 | struct ieee80211com *ic = &sc->sc_ic; |
--- src/sys/dev/pci/if_rtwn.c 2018/12/09 11:14:02 1.18
+++ src/sys/dev/pci/if_rtwn.c 2020/01/30 06:03:34 1.19
@@ -1,39 +1,39 @@ | @@ -1,39 +1,39 @@ | |||
1 | /* $NetBSD: if_rtwn.c,v 1.18 2018/12/09 11:14:02 jdolecek Exp $ */ | 1 | /* $NetBSD: if_rtwn.c,v 1.19 2020/01/30 06:03:34 thorpej Exp $ */ | |
2 | /* $OpenBSD: if_rtwn.c,v 1.5 2015/06/14 08:02:47 stsp Exp $ */ | 2 | /* $OpenBSD: if_rtwn.c,v 1.5 2015/06/14 08:02:47 stsp Exp $ */ | |
3 | #define IEEE80211_NO_HT | 3 | #define IEEE80211_NO_HT | |
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> | 5 | * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr> | |
6 | * Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org> | 6 | * Copyright (c) 2015 Stefan Sperling <stsp@openbsd.org> | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify, and distribute this software for any | 8 | * Permission to use, copy, modify, and distribute this software for any | |
9 | * purpose with or without fee is hereby granted, provided that the above | 9 | * purpose with or without fee is hereby granted, provided that the above | |
10 | * copyright notice and this permission notice appear in all copies. | 10 | * copyright notice and this permission notice appear in all copies. | |
11 | * | 11 | * | |
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
19 | */ | 19 | */ | |
20 | 20 | |||
21 | /* | 21 | /* | |
22 | * Driver for Realtek RTL8188CE | 22 | * Driver for Realtek RTL8188CE | |
23 | */ | 23 | */ | |
24 | 24 | |||
25 | #include <sys/cdefs.h> | 25 | #include <sys/cdefs.h> | |
26 | __KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.18 2018/12/09 11:14:02 jdolecek Exp $"); | 26 | __KERNEL_RCSID(0, "$NetBSD: if_rtwn.c,v 1.19 2020/01/30 06:03:34 thorpej Exp $"); | |
27 | 27 | |||
28 | #include <sys/param.h> | 28 | #include <sys/param.h> | |
29 | #include <sys/sockio.h> | 29 | #include <sys/sockio.h> | |
30 | #include <sys/mbuf.h> | 30 | #include <sys/mbuf.h> | |
31 | #include <sys/kernel.h> | 31 | #include <sys/kernel.h> | |
32 | #include <sys/socket.h> | 32 | #include <sys/socket.h> | |
33 | #include <sys/systm.h> | 33 | #include <sys/systm.h> | |
34 | #include <sys/callout.h> | 34 | #include <sys/callout.h> | |
35 | #include <sys/conf.h> | 35 | #include <sys/conf.h> | |
36 | #include <sys/device.h> | 36 | #include <sys/device.h> | |
37 | #include <sys/endian.h> | 37 | #include <sys/endian.h> | |
38 | #include <sys/mutex.h> | 38 | #include <sys/mutex.h> | |
39 | 39 | |||
@@ -1679,99 +1679,99 @@ rtwn_rx_frame(struct rtwn_softc *sc, str | @@ -1679,99 +1679,99 @@ rtwn_rx_frame(struct rtwn_softc *sc, str | |||
1679 | int8_t rssi = 0; | 1679 | int8_t rssi = 0; | |
1680 | int infosz, pktlen, shift, totlen, error, s; | 1680 | int infosz, pktlen, shift, totlen, error, s; | |
1681 | 1681 | |||
1682 | DPRINTFN(3, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); | 1682 | DPRINTFN(3, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); | |
1683 | 1683 | |||
1684 | rxdw0 = le32toh(rx_desc->rxdw0); | 1684 | rxdw0 = le32toh(rx_desc->rxdw0); | |
1685 | rxdw3 = le32toh(rx_desc->rxdw3); | 1685 | rxdw3 = le32toh(rx_desc->rxdw3); | |
1686 | 1686 | |||
1687 | if (__predict_false(rxdw0 & (R92C_RXDW0_CRCERR | R92C_RXDW0_ICVERR))) { | 1687 | if (__predict_false(rxdw0 & (R92C_RXDW0_CRCERR | R92C_RXDW0_ICVERR))) { | |
1688 | /* | 1688 | /* | |
1689 | * This should not happen since we setup our Rx filter | 1689 | * This should not happen since we setup our Rx filter | |
1690 | * to not receive these frames. | 1690 | * to not receive these frames. | |
1691 | */ | 1691 | */ | |
1692 | ifp->if_ierrors++; | 1692 | if_statinc(ifp, if_ierrors); | |
1693 | return; | 1693 | return; | |
1694 | } | 1694 | } | |
1695 | 1695 | |||
1696 | pktlen = MS(rxdw0, R92C_RXDW0_PKTLEN); | 1696 | pktlen = MS(rxdw0, R92C_RXDW0_PKTLEN); | |
1697 | /* | 1697 | /* | |
1698 | * XXX: This will drop most control packets. Do we really | 1698 | * XXX: This will drop most control packets. Do we really | |
1699 | * want this in IEEE80211_M_MONITOR mode? | 1699 | * want this in IEEE80211_M_MONITOR mode? | |
1700 | */ | 1700 | */ | |
1701 | if (__predict_false(pktlen < (int)sizeof(struct ieee80211_frame_ack))) { | 1701 | if (__predict_false(pktlen < (int)sizeof(struct ieee80211_frame_ack))) { | |
1702 | ic->ic_stats.is_rx_tooshort++; | 1702 | ic->ic_stats.is_rx_tooshort++; | |
1703 | ifp->if_ierrors++; | 1703 | if_statinc(ifp, if_ierrors); | |
1704 | return; | 1704 | return; | |
1705 | } | 1705 | } | |
1706 | if (__predict_false(pktlen > MCLBYTES)) { | 1706 | if (__predict_false(pktlen > MCLBYTES)) { | |
1707 | ifp->if_ierrors++; | 1707 | if_statinc(ifp, if_ierrors); | |
1708 | return; | 1708 | return; | |
1709 | } | 1709 | } | |
1710 | 1710 | |||
1711 | rate = MS(rxdw3, R92C_RXDW3_RATE); | 1711 | rate = MS(rxdw3, R92C_RXDW3_RATE); | |
1712 | infosz = MS(rxdw0, R92C_RXDW0_INFOSZ) * 8; | 1712 | infosz = MS(rxdw0, R92C_RXDW0_INFOSZ) * 8; | |
1713 | if (infosz > sizeof(struct r92c_rx_phystat)) | 1713 | if (infosz > sizeof(struct r92c_rx_phystat)) | |
1714 | infosz = sizeof(struct r92c_rx_phystat); | 1714 | infosz = sizeof(struct r92c_rx_phystat); | |
1715 | shift = MS(rxdw0, R92C_RXDW0_SHIFT); | 1715 | shift = MS(rxdw0, R92C_RXDW0_SHIFT); | |
1716 | totlen = pktlen + infosz + shift; | 1716 | totlen = pktlen + infosz + shift; | |
1717 | 1717 | |||
1718 | /* Get RSSI from PHY status descriptor if present. */ | 1718 | /* Get RSSI from PHY status descriptor if present. */ | |
1719 | if (infosz != 0 && (rxdw0 & R92C_RXDW0_PHYST)) { | 1719 | if (infosz != 0 && (rxdw0 & R92C_RXDW0_PHYST)) { | |
1720 | phy = mtod(rx_data->m, struct r92c_rx_phystat *); | 1720 | phy = mtod(rx_data->m, struct r92c_rx_phystat *); | |
1721 | rssi = rtwn_get_rssi(sc, rate, phy); | 1721 | rssi = rtwn_get_rssi(sc, rate, phy); | |
1722 | /* Update our average RSSI. */ | 1722 | /* Update our average RSSI. */ | |
1723 | rtwn_update_avgrssi(sc, rate, rssi); | 1723 | rtwn_update_avgrssi(sc, rate, rssi); | |
1724 | } | 1724 | } | |
1725 | 1725 | |||
1726 | DPRINTFN(5, ("Rx frame len=%d rate=%d infosz=%d shift=%d rssi=%d\n", | 1726 | DPRINTFN(5, ("Rx frame len=%d rate=%d infosz=%d shift=%d rssi=%d\n", | |
1727 | pktlen, rate, infosz, shift, rssi)); | 1727 | pktlen, rate, infosz, shift, rssi)); | |
1728 | 1728 | |||
1729 | MGETHDR(m1, M_DONTWAIT, MT_DATA); | 1729 | MGETHDR(m1, M_DONTWAIT, MT_DATA); | |
1730 | if (__predict_false(m1 == NULL)) { | 1730 | if (__predict_false(m1 == NULL)) { | |
1731 | ic->ic_stats.is_rx_nobuf++; | 1731 | ic->ic_stats.is_rx_nobuf++; | |
1732 | ifp->if_ierrors++; | 1732 | if_statinc(ifp, if_ierrors); | |
1733 | return; | 1733 | return; | |
1734 | } | 1734 | } | |
1735 | MCLGET(m1, M_DONTWAIT); | 1735 | MCLGET(m1, M_DONTWAIT); | |
1736 | if (__predict_false(!(m1->m_flags & M_EXT))) { | 1736 | if (__predict_false(!(m1->m_flags & M_EXT))) { | |
1737 | m_freem(m1); | 1737 | m_freem(m1); | |
1738 | ic->ic_stats.is_rx_nobuf++; | 1738 | ic->ic_stats.is_rx_nobuf++; | |
1739 | ifp->if_ierrors++; | 1739 | if_statinc(ifp, if_ierrors); | |
1740 | return; | 1740 | return; | |
1741 | } | 1741 | } | |
1742 | 1742 | |||
1743 | bus_dmamap_sync(sc->sc_dmat, rx_data->map, 0, totlen, | 1743 | bus_dmamap_sync(sc->sc_dmat, rx_data->map, 0, totlen, | |
1744 | BUS_DMASYNC_POSTREAD); | 1744 | BUS_DMASYNC_POSTREAD); | |
1745 | 1745 | |||
1746 | bus_dmamap_unload(sc->sc_dmat, rx_data->map); | 1746 | bus_dmamap_unload(sc->sc_dmat, rx_data->map); | |
1747 | error = bus_dmamap_load(sc->sc_dmat, rx_data->map, mtod(m1, void *), | 1747 | error = bus_dmamap_load(sc->sc_dmat, rx_data->map, mtod(m1, void *), | |
1748 | MCLBYTES, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | 1748 | MCLBYTES, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | |
1749 | if (error != 0) { | 1749 | if (error != 0) { | |
1750 | m_freem(m1); | 1750 | m_freem(m1); | |
1751 | 1751 | |||
1752 | if (bus_dmamap_load_mbuf(sc->sc_dmat, rx_data->map, | 1752 | if (bus_dmamap_load_mbuf(sc->sc_dmat, rx_data->map, | |
1753 | rx_data->m, BUS_DMA_NOWAIT)) | 1753 | rx_data->m, BUS_DMA_NOWAIT)) | |
1754 | panic("%s: could not load old RX mbuf", | 1754 | panic("%s: could not load old RX mbuf", | |
1755 | device_xname(sc->sc_dev)); | 1755 | device_xname(sc->sc_dev)); | |
1756 | 1756 | |||
1757 | bus_dmamap_sync(sc->sc_dmat, rx_data->map, 0, MCLBYTES, | 1757 | bus_dmamap_sync(sc->sc_dmat, rx_data->map, 0, MCLBYTES, | |
1758 | BUS_DMASYNC_PREREAD); | 1758 | BUS_DMASYNC_PREREAD); | |
1759 | 1759 | |||
1760 | /* Physical address may have changed. */ | 1760 | /* Physical address may have changed. */ | |
1761 | rtwn_setup_rx_desc(sc, rx_desc, | 1761 | rtwn_setup_rx_desc(sc, rx_desc, | |
1762 | rx_data->map->dm_segs[0].ds_addr, MCLBYTES, desc_idx); | 1762 | rx_data->map->dm_segs[0].ds_addr, MCLBYTES, desc_idx); | |
1763 | 1763 | |||
1764 | ifp->if_ierrors++; | 1764 | if_statinc(ifp, if_ierrors); | |
1765 | return; | 1765 | return; | |
1766 | } | 1766 | } | |
1767 | 1767 | |||
1768 | /* Finalize mbuf. */ | 1768 | /* Finalize mbuf. */ | |
1769 | m = rx_data->m; | 1769 | m = rx_data->m; | |
1770 | rx_data->m = m1; | 1770 | rx_data->m = m1; | |
1771 | m->m_pkthdr.len = m->m_len = totlen; | 1771 | m->m_pkthdr.len = m->m_len = totlen; | |
1772 | m_set_rcvif(m, ifp); | 1772 | m_set_rcvif(m, ifp); | |
1773 | 1773 | |||
1774 | bus_dmamap_sync(sc->sc_dmat, rx_data->map, 0, MCLBYTES, | 1774 | bus_dmamap_sync(sc->sc_dmat, rx_data->map, 0, MCLBYTES, | |
1775 | BUS_DMASYNC_PREREAD); | 1775 | BUS_DMASYNC_PREREAD); | |
1776 | 1776 | |||
1777 | /* Update RX descriptor. */ | 1777 | /* Update RX descriptor. */ | |
@@ -2049,27 +2049,27 @@ rtwn_tx_done(struct rtwn_softc *sc, int | @@ -2049,27 +2049,27 @@ rtwn_tx_done(struct rtwn_softc *sc, int | |||
2049 | if (tx_data->m == NULL) | 2049 | if (tx_data->m == NULL) | |
2050 | continue; | 2050 | continue; | |
2051 | 2051 | |||
2052 | tx_desc = &tx_ring->desc[i]; | 2052 | tx_desc = &tx_ring->desc[i]; | |
2053 | if (le32toh(tx_desc->txdw0) & R92C_TXDW0_OWN) | 2053 | if (le32toh(tx_desc->txdw0) & R92C_TXDW0_OWN) | |
2054 | continue; | 2054 | continue; | |
2055 | 2055 | |||
2056 | bus_dmamap_unload(sc->sc_dmat, tx_data->map); | 2056 | bus_dmamap_unload(sc->sc_dmat, tx_data->map); | |
2057 | m_freem(tx_data->m); | 2057 | m_freem(tx_data->m); | |
2058 | tx_data->m = NULL; | 2058 | tx_data->m = NULL; | |
2059 | ieee80211_free_node(tx_data->ni); | 2059 | ieee80211_free_node(tx_data->ni); | |
2060 | tx_data->ni = NULL; | 2060 | tx_data->ni = NULL; | |
2061 | 2061 | |||
2062 | ifp->if_opackets++; | 2062 | if_statinc(ifp, if_opackets); | |
2063 | sc->sc_tx_timer = 0; | 2063 | sc->sc_tx_timer = 0; | |
2064 | tx_ring->queued--; | 2064 | tx_ring->queued--; | |
2065 | } | 2065 | } | |
2066 | 2066 | |||
2067 | if (tx_ring->queued < RTWN_TX_LIST_LOMARK) | 2067 | if (tx_ring->queued < RTWN_TX_LIST_LOMARK) | |
2068 | sc->qfullmsk &= ~(1 << qid); | 2068 | sc->qfullmsk &= ~(1 << qid); | |
2069 | 2069 | |||
2070 | splx(s); | 2070 | splx(s); | |
2071 | } | 2071 | } | |
2072 | 2072 | |||
2073 | static void | 2073 | static void | |
2074 | rtwn_start(struct ifnet *ifp) | 2074 | rtwn_start(struct ifnet *ifp) | |
2075 | { | 2075 | { | |
@@ -2096,75 +2096,75 @@ rtwn_start(struct ifnet *ifp) | @@ -2096,75 +2096,75 @@ rtwn_start(struct ifnet *ifp) | |||
2096 | M_CLEARCTX(m); | 2096 | M_CLEARCTX(m); | |
2097 | goto sendit; | 2097 | goto sendit; | |
2098 | } | 2098 | } | |
2099 | if (ic->ic_state != IEEE80211_S_RUN) | 2099 | if (ic->ic_state != IEEE80211_S_RUN) | |
2100 | break; | 2100 | break; | |
2101 | 2101 | |||
2102 | /* Encapsulate and send data frames. */ | 2102 | /* Encapsulate and send data frames. */ | |
2103 | IFQ_DEQUEUE(&ifp->if_snd, m); | 2103 | IFQ_DEQUEUE(&ifp->if_snd, m); | |
2104 | if (m == NULL) | 2104 | if (m == NULL) | |
2105 | break; | 2105 | break; | |
2106 | 2106 | |||
2107 | if (m->m_len < (int)sizeof(*eh) && | 2107 | if (m->m_len < (int)sizeof(*eh) && | |
2108 | (m = m_pullup(m, sizeof(*eh))) == NULL) { | 2108 | (m = m_pullup(m, sizeof(*eh))) == NULL) { | |
2109 | ifp->if_oerrors++; | 2109 | if_statinc(ifp, if_oerrors); | |
2110 | continue; | 2110 | continue; | |
2111 | } | 2111 | } | |
2112 | eh = mtod(m, struct ether_header *); | 2112 | eh = mtod(m, struct ether_header *); | |
2113 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | 2113 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | |
2114 | if (ni == NULL) { | 2114 | if (ni == NULL) { | |
2115 | m_freem(m); | 2115 | m_freem(m); | |
2116 | ifp->if_oerrors++; | 2116 | if_statinc(ifp, if_oerrors); | |
2117 | continue; | 2117 | continue; | |
2118 | } | 2118 | } | |
2119 | 2119 | |||
2120 | bpf_mtap(ifp, m, BPF_D_OUT); | 2120 | bpf_mtap(ifp, m, BPF_D_OUT); | |
2121 | 2121 | |||
2122 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) { | 2122 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) { | |
2123 | ieee80211_free_node(ni); | 2123 | ieee80211_free_node(ni); | |
2124 | ifp->if_oerrors++; | 2124 | if_statinc(ifp, if_oerrors); | |
2125 | continue; | 2125 | continue; | |
2126 | } | 2126 | } | |
2127 | sendit: | 2127 | sendit: | |
2128 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | 2128 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | |
2129 | 2129 | |||
2130 | if (rtwn_tx(sc, m, ni) != 0) { | 2130 | if (rtwn_tx(sc, m, ni) != 0) { | |
2131 | ieee80211_free_node(ni); | 2131 | ieee80211_free_node(ni); | |
2132 | ifp->if_oerrors++; | 2132 | if_statinc(ifp, if_oerrors); | |
2133 | continue; | 2133 | continue; | |
2134 | } | 2134 | } | |
2135 | 2135 | |||
2136 | sc->sc_tx_timer = 5; | 2136 | sc->sc_tx_timer = 5; | |
2137 | ifp->if_timer = 1; | 2137 | ifp->if_timer = 1; | |
2138 | } | 2138 | } | |
2139 | 2139 | |||
2140 | DPRINTFN(3, ("%s: %s done\n", device_xname(sc->sc_dev), __func__)); | 2140 | DPRINTFN(3, ("%s: %s done\n", device_xname(sc->sc_dev), __func__)); | |
2141 | } | 2141 | } | |
2142 | 2142 | |||
2143 | static void | 2143 | static void | |
2144 | rtwn_watchdog(struct ifnet *ifp) | 2144 | rtwn_watchdog(struct ifnet *ifp) | |
2145 | { | 2145 | { | |
2146 | struct rtwn_softc *sc = ifp->if_softc; | 2146 | struct rtwn_softc *sc = ifp->if_softc; | |
2147 | struct ieee80211com *ic = &sc->sc_ic; | 2147 | struct ieee80211com *ic = &sc->sc_ic; | |
2148 | 2148 | |||
2149 | DPRINTFN(3, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); | 2149 | DPRINTFN(3, ("%s: %s\n", device_xname(sc->sc_dev), __func__)); | |
2150 | 2150 | |||
2151 | ifp->if_timer = 0; | 2151 | ifp->if_timer = 0; | |
2152 | 2152 | |||
2153 | if (sc->sc_tx_timer > 0) { | 2153 | if (sc->sc_tx_timer > 0) { | |
2154 | if (--sc->sc_tx_timer == 0) { | 2154 | if (--sc->sc_tx_timer == 0) { | |
2155 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | 2155 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | |
2156 | softint_schedule(sc->init_task); | 2156 | softint_schedule(sc->init_task); | |
2157 | ifp->if_oerrors++; | 2157 | if_statinc(ifp, if_oerrors); | |
2158 | return; | 2158 | return; | |
2159 | } | 2159 | } | |
2160 | ifp->if_timer = 1; | 2160 | ifp->if_timer = 1; | |
2161 | } | 2161 | } | |
2162 | ieee80211_watchdog(ic); | 2162 | ieee80211_watchdog(ic); | |
2163 | } | 2163 | } | |
2164 | 2164 | |||
2165 | static int | 2165 | static int | |
2166 | rtwn_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 2166 | rtwn_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
2167 | { | 2167 | { | |
2168 | struct rtwn_softc *sc = ifp->if_softc; | 2168 | struct rtwn_softc *sc = ifp->if_softc; | |
2169 | struct ieee80211com *ic = &sc->sc_ic; | 2169 | struct ieee80211com *ic = &sc->sc_ic; | |
2170 | int s, error = 0; | 2170 | int s, error = 0; |
--- src/sys/dev/pci/if_sk.c 2019/12/27 07:02:26 1.103
+++ src/sys/dev/pci/if_sk.c 2020/01/30 06:03:34 1.104
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_sk.c,v 1.103 2019/12/27 07:02:26 msaitoh Exp $ */ | 1 | /* $NetBSD: if_sk.c,v 1.104 2020/01/30 06:03:34 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2003 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -105,27 +105,27 @@ | @@ -105,27 +105,27 @@ | |||
105 | * interface with DMA support. Each card may have between 512K and | 105 | * interface with DMA support. Each card may have between 512K and | |
106 | * 2MB of SRAM on board depending on the configuration. | 106 | * 2MB of SRAM on board depending on the configuration. | |
107 | * | 107 | * | |
108 | * The SysKonnect GEnesis controller can have either one or two XMAC | 108 | * The SysKonnect GEnesis controller can have either one or two XMAC | |
109 | * chips connected to it, allowing single or dual port NIC configurations. | 109 | * chips connected to it, allowing single or dual port NIC configurations. | |
110 | * SysKonnect has the distinction of being the only vendor on the market | 110 | * SysKonnect has the distinction of being the only vendor on the market | |
111 | * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs, | 111 | * with a dual port gigabit ethernet NIC. The GEnesis provides dual FIFOs, | |
112 | * dual DMA queues, packet/MAC/transmit arbiters and direct access to the | 112 | * dual DMA queues, packet/MAC/transmit arbiters and direct access to the | |
113 | * XMAC registers. This driver takes advantage of these features to allow | 113 | * XMAC registers. This driver takes advantage of these features to allow | |
114 | * both XMACs to operate as independent interfaces. | 114 | * both XMACs to operate as independent interfaces. | |
115 | */ | 115 | */ | |
116 | 116 | |||
117 | #include <sys/cdefs.h> | 117 | #include <sys/cdefs.h> | |
118 | __KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.103 2019/12/27 07:02:26 msaitoh Exp $"); | 118 | __KERNEL_RCSID(0, "$NetBSD: if_sk.c,v 1.104 2020/01/30 06:03:34 thorpej Exp $"); | |
119 | 119 | |||
120 | #include <sys/param.h> | 120 | #include <sys/param.h> | |
121 | #include <sys/systm.h> | 121 | #include <sys/systm.h> | |
122 | #include <sys/sockio.h> | 122 | #include <sys/sockio.h> | |
123 | #include <sys/mbuf.h> | 123 | #include <sys/mbuf.h> | |
124 | #include <sys/malloc.h> | 124 | #include <sys/malloc.h> | |
125 | #include <sys/mutex.h> | 125 | #include <sys/mutex.h> | |
126 | #include <sys/kernel.h> | 126 | #include <sys/kernel.h> | |
127 | #include <sys/socket.h> | 127 | #include <sys/socket.h> | |
128 | #include <sys/device.h> | 128 | #include <sys/device.h> | |
129 | #include <sys/queue.h> | 129 | #include <sys/queue.h> | |
130 | #include <sys/callout.h> | 130 | #include <sys/callout.h> | |
131 | #include <sys/sysctl.h> | 131 | #include <sys/sysctl.h> | |
@@ -2001,27 +2001,27 @@ sk_start(struct ifnet *ifp) | @@ -2001,27 +2001,27 @@ sk_start(struct ifnet *ifp) | |||
2001 | static void | 2001 | static void | |
2002 | sk_watchdog(struct ifnet *ifp) | 2002 | sk_watchdog(struct ifnet *ifp) | |
2003 | { | 2003 | { | |
2004 | struct sk_if_softc *sc_if = ifp->if_softc; | 2004 | struct sk_if_softc *sc_if = ifp->if_softc; | |
2005 | 2005 | |||
2006 | /* | 2006 | /* | |
2007 | * Reclaim first as there is a possibility of losing Tx completion | 2007 | * Reclaim first as there is a possibility of losing Tx completion | |
2008 | * interrupts. | 2008 | * interrupts. | |
2009 | */ | 2009 | */ | |
2010 | sk_txeof(sc_if); | 2010 | sk_txeof(sc_if); | |
2011 | if (sc_if->sk_cdata.sk_tx_cnt != 0) { | 2011 | if (sc_if->sk_cdata.sk_tx_cnt != 0) { | |
2012 | aprint_error_dev(sc_if->sk_dev, "watchdog timeout\n"); | 2012 | aprint_error_dev(sc_if->sk_dev, "watchdog timeout\n"); | |
2013 | 2013 | |||
2014 | ifp->if_oerrors++; | 2014 | if_statinc(ifp, if_oerrors); | |
2015 | 2015 | |||
2016 | sk_init(ifp); | 2016 | sk_init(ifp); | |
2017 | } | 2017 | } | |
2018 | } | 2018 | } | |
2019 | 2019 | |||
2020 | #if 0 /* XXX XXX XXX UNUSED */ | 2020 | #if 0 /* XXX XXX XXX UNUSED */ | |
2021 | static void | 2021 | static void | |
2022 | sk_shutdown(void *v) | 2022 | sk_shutdown(void *v) | |
2023 | { | 2023 | { | |
2024 | struct sk_if_softc *sc_if = (struct sk_if_softc *)v; | 2024 | struct sk_if_softc *sc_if = (struct sk_if_softc *)v; | |
2025 | struct sk_softc *sc = sc_if->sk_softc; | 2025 | struct sk_softc *sc = sc_if->sk_softc; | |
2026 | struct ifnet *ifp = &sc_if->sk_ethercom.ec_if; | 2026 | struct ifnet *ifp = &sc_if->sk_ethercom.ec_if; | |
2027 | 2027 | |||
@@ -2076,47 +2076,47 @@ sk_rxeof(struct sk_if_softc *sc_if) | @@ -2076,47 +2076,47 @@ sk_rxeof(struct sk_if_softc *sc_if) | |||
2076 | bus_dmamap_sync(sc_if->sk_softc->sc_dmatag, dmamap, 0, | 2076 | bus_dmamap_sync(sc_if->sk_softc->sc_dmatag, dmamap, 0, | |
2077 | dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | 2077 | dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); | |
2078 | 2078 | |||
2079 | rxstat = le32toh(cur_desc->sk_xmac_rxstat); | 2079 | rxstat = le32toh(cur_desc->sk_xmac_rxstat); | |
2080 | m = cur_rx->sk_mbuf; | 2080 | m = cur_rx->sk_mbuf; | |
2081 | cur_rx->sk_mbuf = NULL; | 2081 | cur_rx->sk_mbuf = NULL; | |
2082 | total_len = SK_RXBYTES(le32toh(cur_desc->sk_ctl)); | 2082 | total_len = SK_RXBYTES(le32toh(cur_desc->sk_ctl)); | |
2083 | 2083 | |||
2084 | sc_if->sk_cdata.sk_rx_map[cur] = 0; | 2084 | sc_if->sk_cdata.sk_rx_map[cur] = 0; | |
2085 | 2085 | |||
2086 | SK_INC(i, SK_RX_RING_CNT); | 2086 | SK_INC(i, SK_RX_RING_CNT); | |
2087 | 2087 | |||
2088 | if (rxstat & XM_RXSTAT_ERRFRAME) { | 2088 | if (rxstat & XM_RXSTAT_ERRFRAME) { | |
2089 | ifp->if_ierrors++; | 2089 | if_statinc(ifp, if_ierrors); | |
2090 | sk_newbuf(sc_if, cur, m, dmamap); | 2090 | sk_newbuf(sc_if, cur, m, dmamap); | |
2091 | continue; | 2091 | continue; | |
2092 | } | 2092 | } | |
2093 | 2093 | |||
2094 | /* | 2094 | /* | |
2095 | * Try to allocate a new jumbo buffer. If that | 2095 | * Try to allocate a new jumbo buffer. If that | |
2096 | * fails, copy the packet to mbufs and put the | 2096 | * fails, copy the packet to mbufs and put the | |
2097 | * jumbo buffer back in the ring so it can be | 2097 | * jumbo buffer back in the ring so it can be | |
2098 | * re-used. If allocating mbufs fails, then we | 2098 | * re-used. If allocating mbufs fails, then we | |
2099 | * have to drop the packet. | 2099 | * have to drop the packet. | |
2100 | */ | 2100 | */ | |
2101 | if (sk_newbuf(sc_if, cur, NULL, dmamap) == ENOBUFS) { | 2101 | if (sk_newbuf(sc_if, cur, NULL, dmamap) == ENOBUFS) { | |
2102 | struct mbuf *m0; | 2102 | struct mbuf *m0; | |
2103 | m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, | 2103 | m0 = m_devget(mtod(m, char *) - ETHER_ALIGN, | |
2104 | total_len + ETHER_ALIGN, 0, ifp); | 2104 | total_len + ETHER_ALIGN, 0, ifp); | |
2105 | sk_newbuf(sc_if, cur, m, dmamap); | 2105 | sk_newbuf(sc_if, cur, m, dmamap); | |
2106 | if (m0 == NULL) { | 2106 | if (m0 == NULL) { | |
2107 | aprint_error_dev(sc_if->sk_dev, "no receive " | 2107 | aprint_error_dev(sc_if->sk_dev, "no receive " | |
2108 | "buffers available -- packet dropped!\n"); | 2108 | "buffers available -- packet dropped!\n"); | |
2109 | ifp->if_ierrors++; | 2109 | if_statinc(ifp, if_ierrors); | |
2110 | continue; | 2110 | continue; | |
2111 | } | 2111 | } | |
2112 | m_adj(m0, ETHER_ALIGN); | 2112 | m_adj(m0, ETHER_ALIGN); | |
2113 | m = m0; | 2113 | m = m0; | |
2114 | } else { | 2114 | } else { | |
2115 | m_set_rcvif(m, ifp); | 2115 | m_set_rcvif(m, ifp); | |
2116 | m->m_pkthdr.len = m->m_len = total_len; | 2116 | m->m_pkthdr.len = m->m_len = total_len; | |
2117 | } | 2117 | } | |
2118 | 2118 | |||
2119 | /* pass it on. */ | 2119 | /* pass it on. */ | |
2120 | if_percpuq_enqueue(ifp->if_percpuq, m); | 2120 | if_percpuq_enqueue(ifp->if_percpuq, m); | |
2121 | } | 2121 | } | |
2122 | } | 2122 | } | |
@@ -2142,27 +2142,27 @@ sk_txeof(struct sk_if_softc *sc_if) | @@ -2142,27 +2142,27 @@ sk_txeof(struct sk_if_softc *sc_if) | |||
2142 | BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); | 2142 | BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE); | |
2143 | 2143 | |||
2144 | cur_tx = &sc_if->sk_rdata->sk_tx_ring[idx]; | 2144 | cur_tx = &sc_if->sk_rdata->sk_tx_ring[idx]; | |
2145 | sk_ctl = le32toh(cur_tx->sk_ctl); | 2145 | sk_ctl = le32toh(cur_tx->sk_ctl); | |
2146 | #ifdef SK_DEBUG | 2146 | #ifdef SK_DEBUG | |
2147 | if (skdebug >= 3) | 2147 | if (skdebug >= 3) | |
2148 | sk_dump_txdesc(cur_tx, idx); | 2148 | sk_dump_txdesc(cur_tx, idx); | |
2149 | #endif | 2149 | #endif | |
2150 | if (sk_ctl & SK_TXCTL_OWN) { | 2150 | if (sk_ctl & SK_TXCTL_OWN) { | |
2151 | SK_CDTXSYNC(sc_if, idx, 1, BUS_DMASYNC_PREREAD); | 2151 | SK_CDTXSYNC(sc_if, idx, 1, BUS_DMASYNC_PREREAD); | |
2152 | break; | 2152 | break; | |
2153 | } | 2153 | } | |
2154 | if (sk_ctl & SK_TXCTL_LASTFRAG) | 2154 | if (sk_ctl & SK_TXCTL_LASTFRAG) | |
2155 | ifp->if_opackets++; | 2155 | if_statinc(ifp, if_opackets); | |
2156 | if (sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf != NULL) { | 2156 | if (sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf != NULL) { | |
2157 | entry = sc_if->sk_cdata.sk_tx_map[idx]; | 2157 | entry = sc_if->sk_cdata.sk_tx_map[idx]; | |
2158 | 2158 | |||
2159 | m_freem(sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf); | 2159 | m_freem(sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf); | |
2160 | sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf = NULL; | 2160 | sc_if->sk_cdata.sk_tx_chain[idx].sk_mbuf = NULL; | |
2161 | 2161 | |||
2162 | bus_dmamap_sync(sc->sc_dmatag, entry->dmamap, 0, | 2162 | bus_dmamap_sync(sc->sc_dmatag, entry->dmamap, 0, | |
2163 | entry->dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | 2163 | entry->dmamap->dm_mapsize, BUS_DMASYNC_POSTWRITE); | |
2164 | 2164 | |||
2165 | bus_dmamap_unload(sc->sc_dmatag, entry->dmamap); | 2165 | bus_dmamap_unload(sc->sc_dmatag, entry->dmamap); | |
2166 | SIMPLEQ_INSERT_TAIL(&sc_if->sk_txmap_head, entry, | 2166 | SIMPLEQ_INSERT_TAIL(&sc_if->sk_txmap_head, entry, | |
2167 | link); | 2167 | link); | |
2168 | sc_if->sk_cdata.sk_tx_map[idx] = NULL; | 2168 | sc_if->sk_cdata.sk_tx_map[idx] = NULL; |