Adopt <net/if_stats.h>.diff -r1.40 -r1.41 src/sys/dev/ic/aic6915.c
(thorpej)
--- src/sys/dev/ic/aic6915.c 2019/10/30 07:26:28 1.40
+++ src/sys/dev/ic/aic6915.c 2020/01/29 14:09:58 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: aic6915.c,v 1.40 2019/10/30 07:26:28 msaitoh Exp $ */ | 1 | /* $NetBSD: aic6915.c,v 1.41 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -25,27 +25,27 @@ | @@ -25,27 +25,27 @@ | |||
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Device driver for the Adaptec AIC-6915 (``Starfire'') | 33 | * Device driver for the Adaptec AIC-6915 (``Starfire'') | |
34 | * 10/100 Ethernet controller. | 34 | * 10/100 Ethernet controller. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/cdefs.h> | 37 | #include <sys/cdefs.h> | |
38 | __KERNEL_RCSID(0, "$NetBSD: aic6915.c,v 1.40 2019/10/30 07:26:28 msaitoh Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: aic6915.c,v 1.41 2020/01/29 14:09:58 thorpej Exp $"); | |
39 | 39 | |||
40 | 40 | |||
41 | #include <sys/param.h> | 41 | #include <sys/param.h> | |
42 | #include <sys/systm.h> | 42 | #include <sys/systm.h> | |
43 | #include <sys/callout.h> | 43 | #include <sys/callout.h> | |
44 | #include <sys/mbuf.h> | 44 | #include <sys/mbuf.h> | |
45 | #include <sys/malloc.h> | 45 | #include <sys/malloc.h> | |
46 | #include <sys/kernel.h> | 46 | #include <sys/kernel.h> | |
47 | #include <sys/socket.h> | 47 | #include <sys/socket.h> | |
48 | #include <sys/ioctl.h> | 48 | #include <sys/ioctl.h> | |
49 | #include <sys/errno.h> | 49 | #include <sys/errno.h> | |
50 | #include <sys/device.h> | 50 | #include <sys/device.h> | |
51 | 51 | |||
@@ -492,27 +492,27 @@ sf_start(struct ifnet *ifp) | @@ -492,27 +492,27 @@ sf_start(struct ifnet *ifp) | |||
492 | } | 492 | } | |
493 | 493 | |||
494 | /* | 494 | /* | |
495 | * sf_watchdog: [ifnet interface function] | 495 | * sf_watchdog: [ifnet interface function] | |
496 | * | 496 | * | |
497 | * Watchdog timer handler. | 497 | * Watchdog timer handler. | |
498 | */ | 498 | */ | |
499 | static void | 499 | static void | |
500 | sf_watchdog(struct ifnet *ifp) | 500 | sf_watchdog(struct ifnet *ifp) | |
501 | { | 501 | { | |
502 | struct sf_softc *sc = ifp->if_softc; | 502 | struct sf_softc *sc = ifp->if_softc; | |
503 | 503 | |||
504 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | 504 | printf("%s: device timeout\n", device_xname(sc->sc_dev)); | |
505 | ifp->if_oerrors++; | 505 | if_statinc(ifp, if_oerrors); | |
506 | 506 | |||
507 | (void) sf_init(ifp); | 507 | (void) sf_init(ifp); | |
508 | 508 | |||
509 | /* Try to get more packets going. */ | 509 | /* Try to get more packets going. */ | |
510 | sf_start(ifp); | 510 | sf_start(ifp); | |
511 | } | 511 | } | |
512 | 512 | |||
513 | /* | 513 | /* | |
514 | * sf_ioctl: [ifnet interface function] | 514 | * sf_ioctl: [ifnet interface function] | |
515 | * | 515 | * | |
516 | * Handle control requests from the operator. | 516 | * Handle control requests from the operator. | |
517 | */ | 517 | */ | |
518 | static int | 518 | static int | |
@@ -736,43 +736,43 @@ sf_rxintr(struct sf_softc *sc) | @@ -736,43 +736,43 @@ sf_rxintr(struct sf_softc *sc) | |||
736 | * configured the Starfire to NOT transfer the CRC | 736 | * configured the Starfire to NOT transfer the CRC | |
737 | * with the packet. | 737 | * with the packet. | |
738 | */ | 738 | */ | |
739 | len = RCD_W0_Length(word0); | 739 | len = RCD_W0_Length(word0); | |
740 | 740 | |||
741 | #ifdef __NO_STRICT_ALIGNMENT | 741 | #ifdef __NO_STRICT_ALIGNMENT | |
742 | /* | 742 | /* | |
743 | * Allocate a new mbuf cluster. If that fails, we are | 743 | * Allocate a new mbuf cluster. If that fails, we are | |
744 | * out of memory, and must drop the packet and recycle | 744 | * out of memory, and must drop the packet and recycle | |
745 | * the buffer that's already attached to this descriptor. | 745 | * the buffer that's already attached to this descriptor. | |
746 | */ | 746 | */ | |
747 | m = ds->ds_mbuf; | 747 | m = ds->ds_mbuf; | |
748 | if (sf_add_rxbuf(sc, rxidx) != 0) { | 748 | if (sf_add_rxbuf(sc, rxidx) != 0) { | |
749 | ifp->if_ierrors++; | 749 | if_statinc(ifp, if_ierrors); | |
750 | SF_INIT_RXDESC(sc, rxidx); | 750 | SF_INIT_RXDESC(sc, rxidx); | |
751 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | 751 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | |
752 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | 752 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | |
753 | continue; | 753 | continue; | |
754 | } | 754 | } | |
755 | #else | 755 | #else | |
756 | /* | 756 | /* | |
757 | * The Starfire's receive buffer must be 4-byte aligned. | 757 | * The Starfire's receive buffer must be 4-byte aligned. | |
758 | * But this means that the data after the Ethernet header | 758 | * But this means that the data after the Ethernet header | |
759 | * is misaligned. We must allocate a new buffer and | 759 | * is misaligned. We must allocate a new buffer and | |
760 | * copy the data, shifted forward 2 bytes. | 760 | * copy the data, shifted forward 2 bytes. | |
761 | */ | 761 | */ | |
762 | MGETHDR(m, M_DONTWAIT, MT_DATA); | 762 | MGETHDR(m, M_DONTWAIT, MT_DATA); | |
763 | if (m == NULL) { | 763 | if (m == NULL) { | |
764 | dropit: | 764 | dropit: | |
765 | ifp->if_ierrors++; | 765 | if_statinc(ifp, if_ierrors); | |
766 | SF_INIT_RXDESC(sc, rxidx); | 766 | SF_INIT_RXDESC(sc, rxidx); | |
767 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | 767 | bus_dmamap_sync(sc->sc_dmat, ds->ds_dmamap, 0, | |
768 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | 768 | ds->ds_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | |
769 | continue; | 769 | continue; | |
770 | } | 770 | } | |
771 | if (len > (MHLEN - 2)) { | 771 | if (len > (MHLEN - 2)) { | |
772 | MCLGET(m, M_DONTWAIT); | 772 | MCLGET(m, M_DONTWAIT); | |
773 | if ((m->m_flags & M_EXT) == 0) { | 773 | if ((m->m_flags & M_EXT) == 0) { | |
774 | m_freem(m); | 774 | m_freem(m); | |
775 | goto dropit; | 775 | goto dropit; | |
776 | } | 776 | } | |
777 | } | 777 | } | |
778 | m->m_data += 2; | 778 | m->m_data += 2; | |
@@ -836,39 +836,46 @@ sf_stats_update(struct sf_softc *sc) | @@ -836,39 +836,46 @@ sf_stats_update(struct sf_softc *sc) | |||
836 | { | 836 | { | |
837 | struct sf_stats stats; | 837 | struct sf_stats stats; | |
838 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | 838 | struct ifnet *ifp = &sc->sc_ethercom.ec_if; | |
839 | uint32_t *p; | 839 | uint32_t *p; | |
840 | u_int i; | 840 | u_int i; | |
841 | 841 | |||
842 | p = &stats.TransmitOKFrames; | 842 | p = &stats.TransmitOKFrames; | |
843 | for (i = 0; i < (sizeof(stats) / sizeof(uint32_t)); i++) { | 843 | for (i = 0; i < (sizeof(stats) / sizeof(uint32_t)); i++) { | |
844 | *p++ = sf_genreg_read(sc, | 844 | *p++ = sf_genreg_read(sc, | |
845 | SF_STATS_BASE + (i * sizeof(uint32_t))); | 845 | SF_STATS_BASE + (i * sizeof(uint32_t))); | |
846 | sf_genreg_write(sc, SF_STATS_BASE + (i * sizeof(uint32_t)), 0); | 846 | sf_genreg_write(sc, SF_STATS_BASE + (i * sizeof(uint32_t)), 0); | |
847 | } | 847 | } | |
848 | 848 | |||
849 | ifp->if_opackets += stats.TransmitOKFrames; | 849 | net_stat_ref_t nsr = IF_STAT_GETREF(ifp); | |
850 | 850 | |||
851 | ifp->if_collisions += stats.SingleCollisionFrames + | 851 | if_statadd_ref(nsr, if_opackets, stats.TransmitOKFrames); | |
852 | stats.MultipleCollisionFrames; | |||
853 | 852 | |||
854 | ifp->if_oerrors += stats.TransmitAbortDueToExcessiveCollisions + | 853 | if_statadd_ref(nsr, if_collisions, | |
854 | stats.SingleCollisionFrames + | |||
855 | stats.MultipleCollisionFrames); | |||
856 | ||||
857 | if_statadd_ref(nsr, if_oerrors, | |||
858 | stats.TransmitAbortDueToExcessiveCollisions + | |||
855 | stats.TransmitAbortDueToExcessingDeferral + | 859 | stats.TransmitAbortDueToExcessingDeferral + | |
856 | stats.FramesLostDueToInternalTransmitErrors; | 860 | stats.FramesLostDueToInternalTransmitErrors); | |
857 | 861 | |||
858 | ifp->if_ierrors += stats.ReceiveCRCErrors + stats.AlignmentErrors + | 862 | if_statadd_ref(nsr, if_ierrors, | |
863 | stats.ReceiveCRCErrors + stats.AlignmentErrors + | |||
859 | stats.ReceiveFramesTooLong + stats.ReceiveFramesTooShort + | 864 | stats.ReceiveFramesTooLong + stats.ReceiveFramesTooShort + | |
860 | stats.ReceiveFramesJabbersError + | 865 | stats.ReceiveFramesJabbersError + | |
861 | stats.FramesLostDueToInternalReceiveErrors; | 866 | stats.FramesLostDueToInternalReceiveErrors); | |
867 | ||||
868 | IF_STAT_PUTREF(ifp); | |||
862 | } | 869 | } | |
863 | 870 | |||
864 | /* | 871 | /* | |
865 | * sf_reset: | 872 | * sf_reset: | |
866 | * | 873 | * | |
867 | * Perform a soft reset on the Starfire. | 874 | * Perform a soft reset on the Starfire. | |
868 | */ | 875 | */ | |
869 | static void | 876 | static void | |
870 | sf_reset(struct sf_softc *sc) | 877 | sf_reset(struct sf_softc *sc) | |
871 | { | 878 | { | |
872 | int i; | 879 | int i; | |
873 | 880 | |||
874 | sf_funcreg_write(sc, SF_GeneralEthernetCtrl, 0); | 881 | sf_funcreg_write(sc, SF_GeneralEthernetCtrl, 0); |
--- src/sys/dev/ic/an.c 2019/09/23 17:37:04 1.72
+++ src/sys/dev/ic/an.c 2020/01/29 14:09:58 1.73
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $ */ | 1 | /* $NetBSD: an.c,v 1.73 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 1997, 1998, 1999 | 3 | * Copyright (c) 1997, 1998, 1999 | |
4 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | 4 | * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | 14 | * 3. All advertising materials mentioning features or use of this software | |
@@ -67,27 +67,27 @@ | @@ -67,27 +67,27 @@ | |||
67 | * Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD. | 67 | * Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD. | |
68 | * | 68 | * | |
69 | * Written by Bill Paul <wpaul@ctr.columbia.edu> | 69 | * Written by Bill Paul <wpaul@ctr.columbia.edu> | |
70 | * Electrical Engineering Department | 70 | * Electrical Engineering Department | |
71 | * Columbia University, New York City | 71 | * Columbia University, New York City | |
72 | */ | 72 | */ | |
73 | 73 | |||
74 | /* | 74 | /* | |
75 | * Ported to NetBSD from FreeBSD by Atsushi Onoe at the San Diego | 75 | * Ported to NetBSD from FreeBSD by Atsushi Onoe at the San Diego | |
76 | * IETF meeting. | 76 | * IETF meeting. | |
77 | */ | 77 | */ | |
78 | 78 | |||
79 | #include <sys/cdefs.h> | 79 | #include <sys/cdefs.h> | |
80 | __KERNEL_RCSID(0, "$NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $"); | 80 | __KERNEL_RCSID(0, "$NetBSD: an.c,v 1.73 2020/01/29 14:09:58 thorpej Exp $"); | |
81 | 81 | |||
82 | 82 | |||
83 | #include <sys/param.h> | 83 | #include <sys/param.h> | |
84 | #include <sys/callout.h> | 84 | #include <sys/callout.h> | |
85 | #include <sys/sysctl.h> | 85 | #include <sys/sysctl.h> | |
86 | #include <sys/systm.h> | 86 | #include <sys/systm.h> | |
87 | #include <sys/sockio.h> | 87 | #include <sys/sockio.h> | |
88 | #include <sys/mbuf.h> | 88 | #include <sys/mbuf.h> | |
89 | #include <sys/kernel.h> | 89 | #include <sys/kernel.h> | |
90 | #include <sys/ucred.h> | 90 | #include <sys/ucred.h> | |
91 | #include <sys/socket.h> | 91 | #include <sys/socket.h> | |
92 | #include <sys/device.h> | 92 | #include <sys/device.h> | |
93 | #include <sys/proc.h> | 93 | #include <sys/proc.h> | |
@@ -745,27 +745,27 @@ an_start(struct ifnet *ifp) | @@ -745,27 +745,27 @@ an_start(struct ifnet *ifp) | |||
745 | } | 745 | } | |
746 | IFQ_POLL(&ifp->if_snd, m); | 746 | IFQ_POLL(&ifp->if_snd, m); | |
747 | if (m == NULL) { | 747 | if (m == NULL) { | |
748 | DPRINTF2(("an_start: no pending mbuf\n")); | 748 | DPRINTF2(("an_start: no pending mbuf\n")); | |
749 | break; | 749 | break; | |
750 | } | 750 | } | |
751 | if (sc->sc_txd[cur].d_inuse) { | 751 | if (sc->sc_txd[cur].d_inuse) { | |
752 | DPRINTF2(("an_start: %x/%d busy\n", | 752 | DPRINTF2(("an_start: %x/%d busy\n", | |
753 | sc->sc_txd[cur].d_fid, cur)); | 753 | sc->sc_txd[cur].d_fid, cur)); | |
754 | ifp->if_flags |= IFF_OACTIVE; | 754 | ifp->if_flags |= IFF_OACTIVE; | |
755 | break; | 755 | break; | |
756 | } | 756 | } | |
757 | IFQ_DEQUEUE(&ifp->if_snd, m); | 757 | IFQ_DEQUEUE(&ifp->if_snd, m); | |
758 | ifp->if_opackets++; | 758 | if_statinc(ifp, if_opackets); | |
759 | bpf_mtap(ifp, m, BPF_D_OUT); | 759 | bpf_mtap(ifp, m, BPF_D_OUT); | |
760 | eh = mtod(m, struct ether_header *); | 760 | eh = mtod(m, struct ether_header *); | |
761 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | 761 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | |
762 | if (ni == NULL) { | 762 | if (ni == NULL) { | |
763 | /* NB: ieee80211_find_txnode does stat+msg */ | 763 | /* NB: ieee80211_find_txnode does stat+msg */ | |
764 | goto bad; | 764 | goto bad; | |
765 | } | 765 | } | |
766 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) | 766 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) | |
767 | goto bad; | 767 | goto bad; | |
768 | ieee80211_free_node(ni); | 768 | ieee80211_free_node(ni); | |
769 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | 769 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | |
770 | 770 | |||
771 | wh = mtod(m, struct ieee80211_frame *); | 771 | wh = mtod(m, struct ieee80211_frame *); | |
@@ -843,27 +843,27 @@ an_start(struct ifnet *ifp) | @@ -843,27 +843,27 @@ an_start(struct ifnet *ifp) | |||
843 | fid, cur)); | 843 | fid, cur)); | |
844 | sc->sc_txd[cur].d_inuse = 1; | 844 | sc->sc_txd[cur].d_inuse = 1; | |
845 | if (an_cmd(sc, AN_CMD_TX, fid)) { | 845 | if (an_cmd(sc, AN_CMD_TX, fid)) { | |
846 | printf("%s: xmit failed\n", ifp->if_xname); | 846 | printf("%s: xmit failed\n", ifp->if_xname); | |
847 | sc->sc_txd[cur].d_inuse = 0; | 847 | sc->sc_txd[cur].d_inuse = 0; | |
848 | continue; | 848 | continue; | |
849 | } | 849 | } | |
850 | sc->sc_tx_timer = 5; | 850 | sc->sc_tx_timer = 5; | |
851 | ifp->if_timer = 1; | 851 | ifp->if_timer = 1; | |
852 | AN_INC(cur, AN_TX_RING_CNT); | 852 | AN_INC(cur, AN_TX_RING_CNT); | |
853 | sc->sc_txnext = cur; | 853 | sc->sc_txnext = cur; | |
854 | continue; | 854 | continue; | |
855 | bad: | 855 | bad: | |
856 | ifp->if_oerrors++; | 856 | if_statinc(ifp, if_oerrors); | |
857 | m_freem(m); | 857 | m_freem(m); | |
858 | } | 858 | } | |
859 | } | 859 | } | |
860 | 860 | |||
861 | static int | 861 | static int | |
862 | an_reset(struct an_softc *sc) | 862 | an_reset(struct an_softc *sc) | |
863 | { | 863 | { | |
864 | 864 | |||
865 | DPRINTF(("an_reset\n")); | 865 | DPRINTF(("an_reset\n")); | |
866 | 866 | |||
867 | if (!sc->sc_enabled) | 867 | if (!sc->sc_enabled) | |
868 | return ENXIO; | 868 | return ENXIO; | |
869 | 869 | |||
@@ -881,27 +881,27 @@ an_reset(struct an_softc *sc) | @@ -881,27 +881,27 @@ an_reset(struct an_softc *sc) | |||
881 | } | 881 | } | |
882 | 882 | |||
883 | static void | 883 | static void | |
884 | an_watchdog(struct ifnet *ifp) | 884 | an_watchdog(struct ifnet *ifp) | |
885 | { | 885 | { | |
886 | struct an_softc *sc = ifp->if_softc; | 886 | struct an_softc *sc = ifp->if_softc; | |
887 | 887 | |||
888 | if (!sc->sc_enabled) | 888 | if (!sc->sc_enabled) | |
889 | return; | 889 | return; | |
890 | 890 | |||
891 | if (sc->sc_tx_timer) { | 891 | if (sc->sc_tx_timer) { | |
892 | if (--sc->sc_tx_timer == 0) { | 892 | if (--sc->sc_tx_timer == 0) { | |
893 | printf("%s: device timeout\n", ifp->if_xname); | 893 | printf("%s: device timeout\n", ifp->if_xname); | |
894 | ifp->if_oerrors++; | 894 | if_statinc(ifp, if_oerrors); | |
895 | an_init(ifp); | 895 | an_init(ifp); | |
896 | return; | 896 | return; | |
897 | } | 897 | } | |
898 | ifp->if_timer = 1; | 898 | ifp->if_timer = 1; | |
899 | } | 899 | } | |
900 | ieee80211_watchdog(&sc->sc_ic); | 900 | ieee80211_watchdog(&sc->sc_ic); | |
901 | } | 901 | } | |
902 | 902 | |||
903 | static int | 903 | static int | |
904 | an_ioctl(struct ifnet *ifp, u_long command, void *data) | 904 | an_ioctl(struct ifnet *ifp, u_long command, void *data) | |
905 | { | 905 | { | |
906 | struct an_softc *sc = ifp->if_softc; | 906 | struct an_softc *sc = ifp->if_softc; | |
907 | int s, error = 0; | 907 | int s, error = 0; | |
@@ -1380,94 +1380,94 @@ an_rx_intr(struct an_softc *sc) | @@ -1380,94 +1380,94 @@ an_rx_intr(struct an_softc *sc) | |||
1380 | struct ieee80211_frame_min *wh; | 1380 | struct ieee80211_frame_min *wh; | |
1381 | struct ieee80211_node *ni; | 1381 | struct ieee80211_node *ni; | |
1382 | struct an_rxframe frmhdr; | 1382 | struct an_rxframe frmhdr; | |
1383 | struct mbuf *m; | 1383 | struct mbuf *m; | |
1384 | u_int16_t status; | 1384 | u_int16_t status; | |
1385 | int fid, gaplen, len, off, s; | 1385 | int fid, gaplen, len, off, s; | |
1386 | uint8_t *gap; | 1386 | uint8_t *gap; | |
1387 | 1387 | |||
1388 | fid = CSR_READ_2(sc, AN_RX_FID); | 1388 | fid = CSR_READ_2(sc, AN_RX_FID); | |
1389 | 1389 | |||
1390 | /* First read in the frame header */ | 1390 | /* First read in the frame header */ | |
1391 | if (an_read_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr)) != 0) { | 1391 | if (an_read_bap(sc, fid, 0, &frmhdr, sizeof(frmhdr)) != 0) { | |
1392 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | 1392 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | |
1393 | ifp->if_ierrors++; | 1393 | if_statinc(ifp, if_ierrors); | |
1394 | DPRINTF(("an_rx_intr: read fid %x failed\n", fid)); | 1394 | DPRINTF(("an_rx_intr: read fid %x failed\n", fid)); | |
1395 | return; | 1395 | return; | |
1396 | } | 1396 | } | |
1397 | 1397 | |||
1398 | #ifdef AN_DEBUG | 1398 | #ifdef AN_DEBUG | |
1399 | if ((ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) { | 1399 | if ((ifp->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) { | |
1400 | ieee80211_dump_pkt((u_int8_t *)&frmhdr.an_whdr, | 1400 | ieee80211_dump_pkt((u_int8_t *)&frmhdr.an_whdr, | |
1401 | sizeof(struct ieee80211_frame), frmhdr.an_rx_rate, | 1401 | sizeof(struct ieee80211_frame), frmhdr.an_rx_rate, | |
1402 | frmhdr.an_rx_signal_strength); | 1402 | frmhdr.an_rx_signal_strength); | |
1403 | printf(" time 0x%x status 0x%x plen %u chan %u" | 1403 | printf(" time 0x%x status 0x%x plen %u chan %u" | |
1404 | " plcp %02x %02x %02x %02x gap %u\n", | 1404 | " plcp %02x %02x %02x %02x gap %u\n", | |
1405 | le32toh(frmhdr.an_rx_time), le16toh(frmhdr.an_rx_status), | 1405 | le32toh(frmhdr.an_rx_time), le16toh(frmhdr.an_rx_status), | |
1406 | le16toh(frmhdr.an_rx_payload_len), frmhdr.an_rx_chan, | 1406 | le16toh(frmhdr.an_rx_payload_len), frmhdr.an_rx_chan, | |
1407 | frmhdr.an_plcp_hdr[0], frmhdr.an_plcp_hdr[1], | 1407 | frmhdr.an_plcp_hdr[0], frmhdr.an_plcp_hdr[1], | |
1408 | frmhdr.an_plcp_hdr[2], frmhdr.an_plcp_hdr[3], | 1408 | frmhdr.an_plcp_hdr[2], frmhdr.an_plcp_hdr[3], | |
1409 | le16toh(frmhdr.an_gaplen)); | 1409 | le16toh(frmhdr.an_gaplen)); | |
1410 | } | 1410 | } | |
1411 | #endif | 1411 | #endif | |
1412 | 1412 | |||
1413 | status = le16toh(frmhdr.an_rx_status); | 1413 | status = le16toh(frmhdr.an_rx_status); | |
1414 | if ((status & AN_STAT_ERRSTAT) != 0 && | 1414 | if ((status & AN_STAT_ERRSTAT) != 0 && | |
1415 | ic->ic_opmode != IEEE80211_M_MONITOR) { | 1415 | ic->ic_opmode != IEEE80211_M_MONITOR) { | |
1416 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | 1416 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | |
1417 | ifp->if_ierrors++; | 1417 | if_statinc(ifp, if_ierrors); | |
1418 | DPRINTF(("an_rx_intr: fid %x status %x\n", fid, status)); | 1418 | DPRINTF(("an_rx_intr: fid %x status %x\n", fid, status)); | |
1419 | return; | 1419 | return; | |
1420 | } | 1420 | } | |
1421 | 1421 | |||
1422 | /* the payload length field includes a 16-bit "mystery field" */ | 1422 | /* the payload length field includes a 16-bit "mystery field" */ | |
1423 | len = le16toh(frmhdr.an_rx_payload_len) - sizeof(uint16_t); | 1423 | len = le16toh(frmhdr.an_rx_payload_len) - sizeof(uint16_t); | |
1424 | off = ALIGN(sizeof(struct ieee80211_frame)); | 1424 | off = ALIGN(sizeof(struct ieee80211_frame)); | |
1425 | 1425 | |||
1426 | if (off + len > MCLBYTES) { | 1426 | if (off + len > MCLBYTES) { | |
1427 | if (ic->ic_opmode != IEEE80211_M_MONITOR) { | 1427 | if (ic->ic_opmode != IEEE80211_M_MONITOR) { | |
1428 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | 1428 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | |
1429 | ifp->if_ierrors++; | 1429 | if_statinc(ifp, if_ierrors); | |
1430 | DPRINTF(("an_rx_intr: oversized packet %d\n", len)); | 1430 | DPRINTF(("an_rx_intr: oversized packet %d\n", len)); | |
1431 | return; | 1431 | return; | |
1432 | } | 1432 | } | |
1433 | len = 0; | 1433 | len = 0; | |
1434 | } | 1434 | } | |
1435 | 1435 | |||
1436 | MGETHDR(m, M_DONTWAIT, MT_DATA); | 1436 | MGETHDR(m, M_DONTWAIT, MT_DATA); | |
1437 | if (m == NULL) { | 1437 | if (m == NULL) { | |
1438 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | 1438 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | |
1439 | ifp->if_ierrors++; | 1439 | if_statinc(ifp, if_ierrors); | |
1440 | DPRINTF(("an_rx_intr: MGET failed\n")); | 1440 | DPRINTF(("an_rx_intr: MGET failed\n")); | |
1441 | return; | 1441 | return; | |
1442 | } | 1442 | } | |
1443 | if (off + len + AN_GAPLEN_MAX > MHLEN) { | 1443 | if (off + len + AN_GAPLEN_MAX > MHLEN) { | |
1444 | MCLGET(m, M_DONTWAIT); | 1444 | MCLGET(m, M_DONTWAIT); | |
1445 | if ((m->m_flags & M_EXT) == 0) { | 1445 | if ((m->m_flags & M_EXT) == 0) { | |
1446 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | 1446 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | |
1447 | m_freem(m); | 1447 | m_freem(m); | |
1448 | ifp->if_ierrors++; | 1448 | if_statinc(ifp, if_ierrors); | |
1449 | DPRINTF(("an_rx_intr: MCLGET failed\n")); | 1449 | DPRINTF(("an_rx_intr: MCLGET failed\n")); | |
1450 | return; | 1450 | return; | |
1451 | } | 1451 | } | |
1452 | } | 1452 | } | |
1453 | m->m_data += off - sizeof(struct ieee80211_frame); | 1453 | m->m_data += off - sizeof(struct ieee80211_frame); | |
1454 | 1454 | |||
1455 | if (ic->ic_opmode != IEEE80211_M_MONITOR) { | 1455 | if (ic->ic_opmode != IEEE80211_M_MONITOR) { | |
1456 | gaplen = le16toh(frmhdr.an_gaplen); | 1456 | gaplen = le16toh(frmhdr.an_gaplen); | |
1457 | if (gaplen > AN_GAPLEN_MAX) { | 1457 | if (gaplen > AN_GAPLEN_MAX) { | |
1458 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | 1458 | CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_RX); | |
1459 | m_freem(m); | 1459 | m_freem(m); | |
1460 | ifp->if_ierrors++; | 1460 | if_statinc(ifp, if_ierrors); | |
1461 | DPRINTF(("%s: gap too long\n", __func__)); | 1461 | DPRINTF(("%s: gap too long\n", __func__)); | |
1462 | return; | 1462 | return; | |
1463 | } | 1463 | } | |
1464 | /* | 1464 | /* | |
1465 | * We don't need the 16-bit mystery field (payload length?), | 1465 | * We don't need the 16-bit mystery field (payload length?), | |
1466 | * so read it into the region reserved for the 802.11 header. | 1466 | * so read it into the region reserved for the 802.11 header. | |
1467 | * | 1467 | * | |
1468 | * When Cisco Aironet 350 cards w/ firmware version 5 or | 1468 | * When Cisco Aironet 350 cards w/ firmware version 5 or | |
1469 | * greater operate with certain Cisco 350 APs, | 1469 | * greater operate with certain Cisco 350 APs, | |
1470 | * the "gap" is filled with the SNAP header. Read | 1470 | * the "gap" is filled with the SNAP header. Read | |
1471 | * it in after the 802.11 header. | 1471 | * it in after the 802.11 header. | |
1472 | */ | 1472 | */ | |
1473 | gap = m->m_data + sizeof(struct ieee80211_frame) - | 1473 | gap = m->m_data + sizeof(struct ieee80211_frame) - | |
@@ -1539,29 +1539,29 @@ an_tx_intr(struct an_softc *sc, int stat | @@ -1539,29 +1539,29 @@ an_tx_intr(struct an_softc *sc, int stat | |||
1539 | { | 1539 | { | |
1540 | struct ifnet *ifp = &sc->sc_if; | 1540 | struct ifnet *ifp = &sc->sc_if; | |
1541 | int cur, fid, s; | 1541 | int cur, fid, s; | |
1542 | 1542 | |||
1543 | s = splnet(); | 1543 | s = splnet(); | |
1544 | 1544 | |||
1545 | sc->sc_tx_timer = 0; | 1545 | sc->sc_tx_timer = 0; | |
1546 | ifp->if_flags &= ~IFF_OACTIVE; | 1546 | ifp->if_flags &= ~IFF_OACTIVE; | |
1547 | 1547 | |||
1548 | fid = CSR_READ_2(sc, AN_TX_CMP_FID); | 1548 | fid = CSR_READ_2(sc, AN_TX_CMP_FID); | |
1549 | CSR_WRITE_2(sc, AN_EVENT_ACK, status & (AN_EV_TX | AN_EV_TX_EXC)); | 1549 | CSR_WRITE_2(sc, AN_EVENT_ACK, status & (AN_EV_TX | AN_EV_TX_EXC)); | |
1550 | 1550 | |||
1551 | if (status & AN_EV_TX_EXC) | 1551 | if (status & AN_EV_TX_EXC) | |
1552 | ifp->if_oerrors++; | 1552 | if_statinc(ifp, if_oerrors); | |
1553 | else | 1553 | else | |
1554 | ifp->if_opackets++; | 1554 | if_statinc(ifp, if_opackets); | |
1555 | 1555 | |||
1556 | cur = sc->sc_txcur; | 1556 | cur = sc->sc_txcur; | |
1557 | if (sc->sc_txd[cur].d_fid == fid) { | 1557 | if (sc->sc_txd[cur].d_fid == fid) { | |
1558 | sc->sc_txd[cur].d_inuse = 0; | 1558 | sc->sc_txd[cur].d_inuse = 0; | |
1559 | DPRINTF2(("an_tx_intr: sent %x/%d\n", fid, cur)); | 1559 | DPRINTF2(("an_tx_intr: sent %x/%d\n", fid, cur)); | |
1560 | AN_INC(cur, AN_TX_RING_CNT); | 1560 | AN_INC(cur, AN_TX_RING_CNT); | |
1561 | sc->sc_txcur = cur; | 1561 | sc->sc_txcur = cur; | |
1562 | } else { | 1562 | } else { | |
1563 | for (cur = 0; cur < AN_TX_RING_CNT; cur++) { | 1563 | for (cur = 0; cur < AN_TX_RING_CNT; cur++) { | |
1564 | if (fid == sc->sc_txd[cur].d_fid) { | 1564 | if (fid == sc->sc_txd[cur].d_fid) { | |
1565 | sc->sc_txd[cur].d_inuse = 0; | 1565 | sc->sc_txd[cur].d_inuse = 0; | |
1566 | break; | 1566 | break; | |
1567 | } | 1567 | } |
--- src/sys/dev/ic/arn5008.c 2019/11/10 21:16:35 1.16
+++ src/sys/dev/ic/arn5008.c 2020/01/29 14:09:58 1.17
@@ -1,40 +1,40 @@ | @@ -1,40 +1,40 @@ | |||
1 | /* $NetBSD: arn5008.c,v 1.16 2019/11/10 21:16:35 chs Exp $ */ | 1 | /* $NetBSD: arn5008.c,v 1.17 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | /* $OpenBSD: ar5008.c,v 1.21 2012/08/25 12:14:31 kettenis Exp $ */ | 2 | /* $OpenBSD: ar5008.c,v 1.21 2012/08/25 12:14:31 kettenis Exp $ */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> | 5 | * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> | |
6 | * Copyright (c) 2008-2009 Atheros Communications Inc. | 6 | * Copyright (c) 2008-2009 Atheros Communications Inc. | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify, and/or distribute this software for any | 8 | * Permission to use, copy, modify, and/or 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 Atheros 802.11a/g/n chipsets. | 22 | * Driver for Atheros 802.11a/g/n chipsets. | |
23 | * Routines common to AR5008, AR9001 and AR9002 families. | 23 | * Routines common to AR5008, AR9001 and AR9002 families. | |
24 | */ | 24 | */ | |
25 | 25 | |||
26 | #include <sys/cdefs.h> | 26 | #include <sys/cdefs.h> | |
27 | __KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.16 2019/11/10 21:16:35 chs Exp $"); | 27 | __KERNEL_RCSID(0, "$NetBSD: arn5008.c,v 1.17 2020/01/29 14:09:58 thorpej Exp $"); | |
28 | 28 | |||
29 | #include <sys/param.h> | 29 | #include <sys/param.h> | |
30 | #include <sys/sockio.h> | 30 | #include <sys/sockio.h> | |
31 | #include <sys/mbuf.h> | 31 | #include <sys/mbuf.h> | |
32 | #include <sys/kernel.h> | 32 | #include <sys/kernel.h> | |
33 | #include <sys/socket.h> | 33 | #include <sys/socket.h> | |
34 | #include <sys/systm.h> | 34 | #include <sys/systm.h> | |
35 | #include <sys/malloc.h> | 35 | #include <sys/malloc.h> | |
36 | #include <sys/queue.h> | 36 | #include <sys/queue.h> | |
37 | #include <sys/conf.h> | 37 | #include <sys/conf.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | 39 | |||
40 | #include <sys/bus.h> | 40 | #include <sys/bus.h> | |
@@ -812,94 +812,94 @@ ar5008_rx_process(struct athn_softc *sc) | @@ -812,94 +812,94 @@ ar5008_rx_process(struct athn_softc *sc) | |||
812 | * indication that the status words are corrupted, so | 812 | * indication that the status words are corrupted, so | |
813 | * we skip this descriptor and drop the frame. | 813 | * we skip this descriptor and drop the frame. | |
814 | */ | 814 | */ | |
815 | nbf = SIMPLEQ_NEXT(bf, bf_list); | 815 | nbf = SIMPLEQ_NEXT(bf, bf_list); | |
816 | if (nbf != NULL && | 816 | if (nbf != NULL && | |
817 | (((struct ar_rx_desc *)nbf->bf_desc)->ds_status8 & | 817 | (((struct ar_rx_desc *)nbf->bf_desc)->ds_status8 & | |
818 | AR_RXS8_DONE)) { | 818 | AR_RXS8_DONE)) { | |
819 | DPRINTFN(DBG_RX, sc, | 819 | DPRINTFN(DBG_RX, sc, | |
820 | "corrupted descriptor status=0x%x\n", | 820 | "corrupted descriptor status=0x%x\n", | |
821 | ds->ds_status8); | 821 | ds->ds_status8); | |
822 | /* HW will not "move" RXDP in this case, so do it. */ | 822 | /* HW will not "move" RXDP in this case, so do it. */ | |
823 | AR_WRITE(sc, AR_RXDP, nbf->bf_daddr); | 823 | AR_WRITE(sc, AR_RXDP, nbf->bf_daddr); | |
824 | AR_WRITE_BARRIER(sc); | 824 | AR_WRITE_BARRIER(sc); | |
825 | ifp->if_ierrors++; | 825 | if_statinc(ifp, if_ierrors); | |
826 | goto skip; | 826 | goto skip; | |
827 | } | 827 | } | |
828 | return EBUSY; | 828 | return EBUSY; | |
829 | } | 829 | } | |
830 | 830 | |||
831 | if (__predict_false(ds->ds_status1 & AR_RXS1_MORE)) { | 831 | if (__predict_false(ds->ds_status1 & AR_RXS1_MORE)) { | |
832 | /* Drop frames that span multiple Rx descriptors. */ | 832 | /* Drop frames that span multiple Rx descriptors. */ | |
833 | DPRINTFN(DBG_RX, sc, "dropping split frame\n"); | 833 | DPRINTFN(DBG_RX, sc, "dropping split frame\n"); | |
834 | ifp->if_ierrors++; | 834 | if_statinc(ifp, if_ierrors); | |
835 | goto skip; | 835 | goto skip; | |
836 | } | 836 | } | |
837 | if (!(ds->ds_status8 & AR_RXS8_FRAME_OK)) { | 837 | if (!(ds->ds_status8 & AR_RXS8_FRAME_OK)) { | |
838 | if (ds->ds_status8 & AR_RXS8_CRC_ERR) | 838 | if (ds->ds_status8 & AR_RXS8_CRC_ERR) | |
839 | DPRINTFN(DBG_RX, sc, "CRC error\n"); | 839 | DPRINTFN(DBG_RX, sc, "CRC error\n"); | |
840 | else if (ds->ds_status8 & AR_RXS8_PHY_ERR) | 840 | else if (ds->ds_status8 & AR_RXS8_PHY_ERR) | |
841 | DPRINTFN(DBG_RX, sc, "PHY error=0x%x\n", | 841 | DPRINTFN(DBG_RX, sc, "PHY error=0x%x\n", | |
842 | MS(ds->ds_status8, AR_RXS8_PHY_ERR_CODE)); | 842 | MS(ds->ds_status8, AR_RXS8_PHY_ERR_CODE)); | |
843 | else if (ds->ds_status8 & AR_RXS8_DECRYPT_CRC_ERR) | 843 | else if (ds->ds_status8 & AR_RXS8_DECRYPT_CRC_ERR) | |
844 | DPRINTFN(DBG_RX, sc, "Decryption CRC error\n"); | 844 | DPRINTFN(DBG_RX, sc, "Decryption CRC error\n"); | |
845 | else if (ds->ds_status8 & AR_RXS8_MICHAEL_ERR) { | 845 | else if (ds->ds_status8 & AR_RXS8_MICHAEL_ERR) { | |
846 | DPRINTFN(DBG_RX, sc, "Michael MIC failure\n"); | 846 | DPRINTFN(DBG_RX, sc, "Michael MIC failure\n"); | |
847 | 847 | |||
848 | len = MS(ds->ds_status1, AR_RXS1_DATA_LEN); | 848 | len = MS(ds->ds_status1, AR_RXS1_DATA_LEN); | |
849 | m = bf->bf_m; | 849 | m = bf->bf_m; | |
850 | m_set_rcvif(m, ifp); | 850 | m_set_rcvif(m, ifp); | |
851 | m->m_pkthdr.len = m->m_len = len; | 851 | m->m_pkthdr.len = m->m_len = len; | |
852 | wh = mtod(m, struct ieee80211_frame *); | 852 | wh = mtod(m, struct ieee80211_frame *); | |
853 | 853 | |||
854 | /* Report Michael MIC failures to net80211. */ | 854 | /* Report Michael MIC failures to net80211. */ | |
855 | ieee80211_notify_michael_failure(ic, wh, 0 /* XXX: keyix */); | 855 | ieee80211_notify_michael_failure(ic, wh, 0 /* XXX: keyix */); | |
856 | } | 856 | } | |
857 | ifp->if_ierrors++; | 857 | if_statinc(ifp, if_ierrors); | |
858 | goto skip; | 858 | goto skip; | |
859 | } | 859 | } | |
860 | 860 | |||
861 | len = MS(ds->ds_status1, AR_RXS1_DATA_LEN); | 861 | len = MS(ds->ds_status1, AR_RXS1_DATA_LEN); | |
862 | if (__predict_false(len < (int)IEEE80211_MIN_LEN || len > ATHN_RXBUFSZ)) { | 862 | if (__predict_false(len < (int)IEEE80211_MIN_LEN || len > ATHN_RXBUFSZ)) { | |
863 | DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%d\n", len); | 863 | DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%d\n", len); | |
864 | ifp->if_ierrors++; | 864 | if_statinc(ifp, if_ierrors); | |
865 | goto skip; | 865 | goto skip; | |
866 | } | 866 | } | |
867 | 867 | |||
868 | /* Allocate a new Rx buffer. */ | 868 | /* Allocate a new Rx buffer. */ | |
869 | m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ); | 869 | m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ); | |
870 | if (__predict_false(m1 == NULL)) { | 870 | if (__predict_false(m1 == NULL)) { | |
871 | ic->ic_stats.is_rx_nobuf++; | 871 | ic->ic_stats.is_rx_nobuf++; | |
872 | ifp->if_ierrors++; | 872 | if_statinc(ifp, if_ierrors); | |
873 | goto skip; | 873 | goto skip; | |
874 | } | 874 | } | |
875 | 875 | |||
876 | /* Sync and unmap the old Rx buffer. */ | 876 | /* Sync and unmap the old Rx buffer. */ | |
877 | bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ, | 877 | bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ, | |
878 | BUS_DMASYNC_POSTREAD); | 878 | BUS_DMASYNC_POSTREAD); | |
879 | bus_dmamap_unload(sc->sc_dmat, bf->bf_map); | 879 | bus_dmamap_unload(sc->sc_dmat, bf->bf_map); | |
880 | 880 | |||
881 | /* Map the new Rx buffer. */ | 881 | /* Map the new Rx buffer. */ | |
882 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, mtod(m1, void *), | 882 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, mtod(m1, void *), | |
883 | ATHN_RXBUFSZ, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | 883 | ATHN_RXBUFSZ, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | |
884 | if (__predict_false(error != 0)) { | 884 | if (__predict_false(error != 0)) { | |
885 | m_freem(m1); | 885 | m_freem(m1); | |
886 | 886 | |||
887 | /* Remap the old Rx buffer or panic. */ | 887 | /* Remap the old Rx buffer or panic. */ | |
888 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, | 888 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, | |
889 | mtod(bf->bf_m, void *), ATHN_RXBUFSZ, NULL, | 889 | mtod(bf->bf_m, void *), ATHN_RXBUFSZ, NULL, | |
890 | BUS_DMA_NOWAIT | BUS_DMA_READ); | 890 | BUS_DMA_NOWAIT | BUS_DMA_READ); | |
891 | KASSERT(error != 0); | 891 | KASSERT(error != 0); | |
892 | ifp->if_ierrors++; | 892 | if_statinc(ifp, if_ierrors); | |
893 | goto skip; | 893 | goto skip; | |
894 | } | 894 | } | |
895 | 895 | |||
896 | bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ, | 896 | bus_dmamap_sync(sc->sc_dmat, bf->bf_map, 0, ATHN_RXBUFSZ, | |
897 | BUS_DMASYNC_PREREAD); | 897 | BUS_DMASYNC_PREREAD); | |
898 | 898 | |||
899 | /* Write physical address of new Rx buffer. */ | 899 | /* Write physical address of new Rx buffer. */ | |
900 | ds->ds_data = bf->bf_map->dm_segs[0].ds_addr; | 900 | ds->ds_data = bf->bf_map->dm_segs[0].ds_addr; | |
901 | 901 | |||
902 | m = bf->bf_m; | 902 | m = bf->bf_m; | |
903 | bf->bf_m = m1; | 903 | bf->bf_m = m1; | |
904 | 904 | |||
905 | /* Finalize mbuf. */ | 905 | /* Finalize mbuf. */ | |
@@ -975,32 +975,32 @@ ar5008_tx_process(struct athn_softc *sc, | @@ -975,32 +975,32 @@ ar5008_tx_process(struct athn_softc *sc, | |||
975 | struct ar_tx_desc *ds; | 975 | struct ar_tx_desc *ds; | |
976 | uint8_t failcnt; | 976 | uint8_t failcnt; | |
977 | 977 | |||
978 | bf = SIMPLEQ_FIRST(&txq->head); | 978 | bf = SIMPLEQ_FIRST(&txq->head); | |
979 | if (bf == NULL) | 979 | if (bf == NULL) | |
980 | return ENOENT; | 980 | return ENOENT; | |
981 | /* Get descriptor of last DMA segment. */ | 981 | /* Get descriptor of last DMA segment. */ | |
982 | ds = &((struct ar_tx_desc *)bf->bf_descs)[bf->bf_map->dm_nsegs - 1]; | 982 | ds = &((struct ar_tx_desc *)bf->bf_descs)[bf->bf_map->dm_nsegs - 1]; | |
983 | 983 | |||
984 | if (!(ds->ds_status9 & AR_TXS9_DONE)) | 984 | if (!(ds->ds_status9 & AR_TXS9_DONE)) | |
985 | return EBUSY; | 985 | return EBUSY; | |
986 | 986 | |||
987 | SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list); | 987 | SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list); | |
988 | ifp->if_opackets++; | 988 | if_statinc(ifp, if_opackets); | |
989 | 989 | |||
990 | sc->sc_tx_timer = 0; | 990 | sc->sc_tx_timer = 0; | |
991 | 991 | |||
992 | if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES) | 992 | if (ds->ds_status1 & AR_TXS1_EXCESSIVE_RETRIES) | |
993 | ifp->if_oerrors++; | 993 | if_statinc(ifp, if_oerrors); | |
994 | 994 | |||
995 | if (ds->ds_status1 & AR_TXS1_UNDERRUN) | 995 | if (ds->ds_status1 & AR_TXS1_UNDERRUN) | |
996 | athn_inc_tx_trigger_level(sc); | 996 | athn_inc_tx_trigger_level(sc); | |
997 | 997 | |||
998 | an = (struct athn_node *)bf->bf_ni; | 998 | an = (struct athn_node *)bf->bf_ni; | |
999 | /* | 999 | /* | |
1000 | * NB: the data fail count contains the number of un-acked tries | 1000 | * NB: the data fail count contains the number of un-acked tries | |
1001 | * for the final series used. We must add the number of tries for | 1001 | * for the final series used. We must add the number of tries for | |
1002 | * each series that was fully processed. | 1002 | * each series that was fully processed. | |
1003 | */ | 1003 | */ | |
1004 | failcnt = MS(ds->ds_status1, AR_TXS1_DATA_FAIL_CNT); | 1004 | failcnt = MS(ds->ds_status1, AR_TXS1_DATA_FAIL_CNT); | |
1005 | /* NB: Assume two tries per series. */ | 1005 | /* NB: Assume two tries per series. */ | |
1006 | failcnt += MS(ds->ds_status9, AR_TXS9_FINAL_IDX) * 2; | 1006 | failcnt += MS(ds->ds_status9, AR_TXS9_FINAL_IDX) * 2; | |
@@ -1161,27 +1161,27 @@ ar5008_swba_intr(struct athn_softc *sc) | @@ -1161,27 +1161,27 @@ ar5008_swba_intr(struct athn_softc *sc) | |||
1161 | break; | 1161 | break; | |
1162 | 1162 | |||
1163 | IF_DEQUEUE(&ni->ni_savedq, m); | 1163 | IF_DEQUEUE(&ni->ni_savedq, m); | |
1164 | if (m == NULL) | 1164 | if (m == NULL) | |
1165 | break; | 1165 | break; | |
1166 | if (!IF_IS_EMPTY(&ni->ni_savedq)) { | 1166 | if (!IF_IS_EMPTY(&ni->ni_savedq)) { | |
1167 | /* more queued frames, set the more data bit */ | 1167 | /* more queued frames, set the more data bit */ | |
1168 | wh = mtod(m, struct ieee80211_frame *); | 1168 | wh = mtod(m, struct ieee80211_frame *); | |
1169 | wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; | 1169 | wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; | |
1170 | } | 1170 | } | |
1171 | 1171 | |||
1172 | if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) { | 1172 | if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) { | |
1173 | ieee80211_free_node(ni); | 1173 | ieee80211_free_node(ni); | |
1174 | ifp->if_oerrors++; | 1174 | if_statinc(ifp, if_oerrors); | |
1175 | break; | 1175 | break; | |
1176 | } | 1176 | } | |
1177 | } | 1177 | } | |
1178 | 1178 | |||
1179 | /* Kick Tx. */ | 1179 | /* Kick Tx. */ | |
1180 | AR_WRITE(sc, AR_Q_TXE, 1 << ATHN_QID_BEACON); | 1180 | AR_WRITE(sc, AR_Q_TXE, 1 << ATHN_QID_BEACON); | |
1181 | AR_WRITE_BARRIER(sc); | 1181 | AR_WRITE_BARRIER(sc); | |
1182 | return 0; | 1182 | return 0; | |
1183 | } | 1183 | } | |
1184 | #endif | 1184 | #endif | |
1185 | 1185 | |||
1186 | static int | 1186 | static int | |
1187 | ar5008_get_intr_status(struct athn_softc *sc, uint32_t *intrp, uint32_t *syncp) | 1187 | ar5008_get_intr_status(struct athn_softc *sc, uint32_t *intrp, uint32_t *syncp) |
--- src/sys/dev/ic/arn9003.c 2019/11/10 21:16:35 1.14
+++ src/sys/dev/ic/arn9003.c 2020/01/29 14:09:58 1.15
@@ -1,40 +1,40 @@ | @@ -1,40 +1,40 @@ | |||
1 | /* $NetBSD: arn9003.c,v 1.14 2019/11/10 21:16:35 chs Exp $ */ | 1 | /* $NetBSD: arn9003.c,v 1.15 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | /* $OpenBSD: ar9003.c,v 1.25 2012/10/20 09:53:32 stsp Exp $ */ | 2 | /* $OpenBSD: ar9003.c,v 1.25 2012/10/20 09:53:32 stsp Exp $ */ | |
3 | 3 | |||
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) 2010 Atheros Communications Inc. | 6 | * Copyright (c) 2010 Atheros Communications Inc. | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify, and/or distribute this software for any | 8 | * Permission to use, copy, modify, and/or 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 Atheros 802.11a/g/n chipsets. | 22 | * Driver for Atheros 802.11a/g/n chipsets. | |
23 | * Routines for AR9003 family. | 23 | * Routines for AR9003 family. | |
24 | */ | 24 | */ | |
25 | 25 | |||
26 | #include <sys/cdefs.h> | 26 | #include <sys/cdefs.h> | |
27 | __KERNEL_RCSID(0, "$NetBSD: arn9003.c,v 1.14 2019/11/10 21:16:35 chs Exp $"); | 27 | __KERNEL_RCSID(0, "$NetBSD: arn9003.c,v 1.15 2020/01/29 14:09:58 thorpej Exp $"); | |
28 | 28 | |||
29 | #include <sys/param.h> | 29 | #include <sys/param.h> | |
30 | #include <sys/sockio.h> | 30 | #include <sys/sockio.h> | |
31 | #include <sys/mbuf.h> | 31 | #include <sys/mbuf.h> | |
32 | #include <sys/kernel.h> | 32 | #include <sys/kernel.h> | |
33 | #include <sys/socket.h> | 33 | #include <sys/socket.h> | |
34 | #include <sys/systm.h> | 34 | #include <sys/systm.h> | |
35 | #include <sys/malloc.h> | 35 | #include <sys/malloc.h> | |
36 | #include <sys/queue.h> | 36 | #include <sys/queue.h> | |
37 | #include <sys/callout.h> | 37 | #include <sys/callout.h> | |
38 | #include <sys/conf.h> | 38 | #include <sys/conf.h> | |
39 | #include <sys/device.h> | 39 | #include <sys/device.h> | |
40 | 40 | |||
@@ -975,63 +975,63 @@ ar9003_rx_process(struct athn_softc *sc, | @@ -975,63 +975,63 @@ ar9003_rx_process(struct athn_softc *sc, | |||
975 | DPRINTFN(DBG_RX, sc, "Michael MIC failure\n"); | 975 | DPRINTFN(DBG_RX, sc, "Michael MIC failure\n"); | |
976 | /* Report Michael MIC failures to net80211. */ | 976 | /* Report Michael MIC failures to net80211. */ | |
977 | 977 | |||
978 | len = MS(ds->ds_status2, AR_RXS2_DATA_LEN); | 978 | len = MS(ds->ds_status2, AR_RXS2_DATA_LEN); | |
979 | m = bf->bf_m; | 979 | m = bf->bf_m; | |
980 | m_set_rcvif(m, ifp); | 980 | m_set_rcvif(m, ifp); | |
981 | m->m_data = (void *)&ds[1]; | 981 | m->m_data = (void *)&ds[1]; | |
982 | m->m_pkthdr.len = m->m_len = len; | 982 | m->m_pkthdr.len = m->m_len = len; | |
983 | wh = mtod(m, struct ieee80211_frame *); | 983 | wh = mtod(m, struct ieee80211_frame *); | |
984 | 984 | |||
985 | ieee80211_notify_michael_failure(ic, wh, | 985 | ieee80211_notify_michael_failure(ic, wh, | |
986 | 0 /* XXX: keyix */); | 986 | 0 /* XXX: keyix */); | |
987 | } | 987 | } | |
988 | ifp->if_ierrors++; | 988 | if_statinc(ifp, if_ierrors); | |
989 | goto skip; | 989 | goto skip; | |
990 | } | 990 | } | |
991 | 991 | |||
992 | len = MS(ds->ds_status2, AR_RXS2_DATA_LEN); | 992 | len = MS(ds->ds_status2, AR_RXS2_DATA_LEN); | |
993 | if (__predict_false(len < IEEE80211_MIN_LEN || | 993 | if (__predict_false(len < IEEE80211_MIN_LEN || | |
994 | len > ATHN_RXBUFSZ - sizeof(*ds))) { | 994 | len > ATHN_RXBUFSZ - sizeof(*ds))) { | |
995 | DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%zd\n", | 995 | DPRINTFN(DBG_RX, sc, "corrupted descriptor length=%zd\n", | |
996 | len); | 996 | len); | |
997 | ifp->if_ierrors++; | 997 | if_statinc(ifp, if_ierrors); | |
998 | goto skip; | 998 | goto skip; | |
999 | } | 999 | } | |
1000 | 1000 | |||
1001 | /* Allocate a new Rx buffer. */ | 1001 | /* Allocate a new Rx buffer. */ | |
1002 | m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ); | 1002 | m1 = MCLGETI(NULL, M_DONTWAIT, NULL, ATHN_RXBUFSZ); | |
1003 | if (__predict_false(m1 == NULL)) { | 1003 | if (__predict_false(m1 == NULL)) { | |
1004 | ic->ic_stats.is_rx_nobuf++; | 1004 | ic->ic_stats.is_rx_nobuf++; | |
1005 | ifp->if_ierrors++; | 1005 | if_statinc(ifp, if_ierrors); | |
1006 | goto skip; | 1006 | goto skip; | |
1007 | } | 1007 | } | |
1008 | 1008 | |||
1009 | /* Unmap the old Rx buffer. */ | 1009 | /* Unmap the old Rx buffer. */ | |
1010 | bus_dmamap_unload(sc->sc_dmat, bf->bf_map); | 1010 | bus_dmamap_unload(sc->sc_dmat, bf->bf_map); | |
1011 | 1011 | |||
1012 | /* Map the new Rx buffer. */ | 1012 | /* Map the new Rx buffer. */ | |
1013 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, mtod(m1, void *), | 1013 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, mtod(m1, void *), | |
1014 | ATHN_RXBUFSZ, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | 1014 | ATHN_RXBUFSZ, NULL, BUS_DMA_NOWAIT | BUS_DMA_READ); | |
1015 | if (__predict_false(error != 0)) { | 1015 | if (__predict_false(error != 0)) { | |
1016 | m_freem(m1); | 1016 | m_freem(m1); | |
1017 | 1017 | |||
1018 | /* Remap the old Rx buffer or panic. */ | 1018 | /* Remap the old Rx buffer or panic. */ | |
1019 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, | 1019 | error = bus_dmamap_load(sc->sc_dmat, bf->bf_map, | |
1020 | mtod(bf->bf_m, void *), ATHN_RXBUFSZ, NULL, | 1020 | mtod(bf->bf_m, void *), ATHN_RXBUFSZ, NULL, | |
1021 | BUS_DMA_NOWAIT | BUS_DMA_READ); | 1021 | BUS_DMA_NOWAIT | BUS_DMA_READ); | |
1022 | KASSERT(error != 0); | 1022 | KASSERT(error != 0); | |
1023 | bf->bf_daddr = bf->bf_map->dm_segs[0].ds_addr; | 1023 | bf->bf_daddr = bf->bf_map->dm_segs[0].ds_addr; | |
1024 | ifp->if_ierrors++; | 1024 | if_statinc(ifp, if_ierrors); | |
1025 | goto skip; | 1025 | goto skip; | |
1026 | } | 1026 | } | |
1027 | bf->bf_desc = mtod(m1, struct ar_rx_status *); | 1027 | bf->bf_desc = mtod(m1, struct ar_rx_status *); | |
1028 | bf->bf_daddr = bf->bf_map->dm_segs[0].ds_addr; | 1028 | bf->bf_daddr = bf->bf_map->dm_segs[0].ds_addr; | |
1029 | 1029 | |||
1030 | m = bf->bf_m; | 1030 | m = bf->bf_m; | |
1031 | bf->bf_m = m1; | 1031 | bf->bf_m = m1; | |
1032 | 1032 | |||
1033 | /* Finalize mbuf. */ | 1033 | /* Finalize mbuf. */ | |
1034 | m_set_rcvif(m, ifp); | 1034 | m_set_rcvif(m, ifp); | |
1035 | /* Strip Rx status descriptor from head. */ | 1035 | /* Strip Rx status descriptor from head. */ | |
1036 | m->m_data = (void *)&ds[1]; | 1036 | m->m_data = (void *)&ds[1]; | |
1037 | m->m_pkthdr.len = m->m_len = len; | 1037 | m->m_pkthdr.len = m->m_len = len; | |
@@ -1117,32 +1117,32 @@ ar9003_tx_process(struct athn_softc *sc) | @@ -1117,32 +1117,32 @@ ar9003_tx_process(struct athn_softc *sc) | |||
1117 | memset(ds, 0, sizeof(*ds)); | 1117 | memset(ds, 0, sizeof(*ds)); | |
1118 | return 0; | 1118 | return 0; | |
1119 | } | 1119 | } | |
1120 | /* Retrieve the queue that was used to send this PDU. */ | 1120 | /* Retrieve the queue that was used to send this PDU. */ | |
1121 | qid = MS(ds->ds_info, AR_TXI_QCU_NUM); | 1121 | qid = MS(ds->ds_info, AR_TXI_QCU_NUM); | |
1122 | txq = &sc->sc_txq[qid]; | 1122 | txq = &sc->sc_txq[qid]; | |
1123 | 1123 | |||
1124 | bf = SIMPLEQ_FIRST(&txq->head); | 1124 | bf = SIMPLEQ_FIRST(&txq->head); | |
1125 | if (bf == NULL || bf == txq->wait) { | 1125 | if (bf == NULL || bf == txq->wait) { | |
1126 | memset(ds, 0, sizeof(*ds)); | 1126 | memset(ds, 0, sizeof(*ds)); | |
1127 | return 0; | 1127 | return 0; | |
1128 | } | 1128 | } | |
1129 | SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list); | 1129 | SIMPLEQ_REMOVE_HEAD(&txq->head, bf_list); | |
1130 | ifp->if_opackets++; | 1130 | if_statinc(ifp, if_opackets); | |
1131 | 1131 | |||
1132 | sc->sc_tx_timer = 0; | 1132 | sc->sc_tx_timer = 0; | |
1133 | 1133 | |||
1134 | if (ds->ds_status3 & AR_TXS3_EXCESSIVE_RETRIES) | 1134 | if (ds->ds_status3 & AR_TXS3_EXCESSIVE_RETRIES) | |
1135 | ifp->if_oerrors++; | 1135 | if_statinc(ifp, if_oerrors); | |
1136 | 1136 | |||
1137 | if (ds->ds_status3 & AR_TXS3_UNDERRUN) | 1137 | if (ds->ds_status3 & AR_TXS3_UNDERRUN) | |
1138 | athn_inc_tx_trigger_level(sc); | 1138 | athn_inc_tx_trigger_level(sc); | |
1139 | 1139 | |||
1140 | /* Wakeup PA predistortion state machine. */ | 1140 | /* Wakeup PA predistortion state machine. */ | |
1141 | if (bf->bf_txflags & ATHN_TXFLAG_PAPRD) | 1141 | if (bf->bf_txflags & ATHN_TXFLAG_PAPRD) | |
1142 | ar9003_paprd_tx_tone_done(sc); | 1142 | ar9003_paprd_tx_tone_done(sc); | |
1143 | 1143 | |||
1144 | an = (struct athn_node *)bf->bf_ni; | 1144 | an = (struct athn_node *)bf->bf_ni; | |
1145 | /* | 1145 | /* | |
1146 | * NB: the data fail count contains the number of un-acked tries | 1146 | * NB: the data fail count contains the number of un-acked tries | |
1147 | * for the final series used. We must add the number of tries for | 1147 | * for the final series used. We must add the number of tries for | |
1148 | * each series that was fully processed. | 1148 | * each series that was fully processed. | |
@@ -1319,27 +1319,27 @@ ar9003_swba_intr(struct athn_softc *sc) | @@ -1319,27 +1319,27 @@ ar9003_swba_intr(struct athn_softc *sc) | |||
1319 | break; | 1319 | break; | |
1320 | 1320 | |||
1321 | IF_DEQUEUE(&ni->ni_savedq, m); | 1321 | IF_DEQUEUE(&ni->ni_savedq, m); | |
1322 | if (m == NULL) | 1322 | if (m == NULL) | |
1323 | break; | 1323 | break; | |
1324 | if (!IF_IS_EMPTY(&ni->ni_savedq)) { | 1324 | if (!IF_IS_EMPTY(&ni->ni_savedq)) { | |
1325 | /* more queued frames, set the more data bit */ | 1325 | /* more queued frames, set the more data bit */ | |
1326 | wh = mtod(m, struct ieee80211_frame *); | 1326 | wh = mtod(m, struct ieee80211_frame *); | |
1327 | wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; | 1327 | wh->i_fc[1] |= IEEE80211_FC1_MORE_DATA; | |
1328 | } | 1328 | } | |
1329 | 1329 | |||
1330 | if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) { | 1330 | if (sc->sc_ops.tx(sc, m, ni, ATHN_TXFLAG_CAB) != 0) { | |
1331 | ieee80211_free_node(ni); | 1331 | ieee80211_free_node(ni); | |
1332 | ifp->if_oerrors++; | 1332 | if_statinc(ifp, if_oerrors); | |
1333 | break; | 1333 | break; | |
1334 | } | 1334 | } | |
1335 | } | 1335 | } | |
1336 | 1336 | |||
1337 | /* Kick Tx. */ | 1337 | /* Kick Tx. */ | |
1338 | AR_WRITE(sc, AR_Q_TXE, 1 << ATHN_QID_BEACON); | 1338 | AR_WRITE(sc, AR_Q_TXE, 1 << ATHN_QID_BEACON); | |
1339 | AR_WRITE_BARRIER(sc); | 1339 | AR_WRITE_BARRIER(sc); | |
1340 | return 0; | 1340 | return 0; | |
1341 | } | 1341 | } | |
1342 | #endif | 1342 | #endif | |
1343 | 1343 | |||
1344 | static int | 1344 | static int | |
1345 | ar9003_get_intr_status(struct athn_softc *sc, uint32_t *intrp, uint32_t *syncp) | 1345 | ar9003_get_intr_status(struct athn_softc *sc, uint32_t *intrp, uint32_t *syncp) |
--- src/sys/dev/ic/ath.c 2019/12/17 04:54:36 1.129
+++ src/sys/dev/ic/ath.c 2020/01/29 14:09:58 1.130
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ath.c,v 1.129 2019/12/17 04:54:36 christos Exp $ */ | 1 | /* $NetBSD: ath.c,v 1.130 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | 4 | * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting | |
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 | * without modification. | 12 | * without modification. | |
13 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 13 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
14 | * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any | 14 | * similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any | |
@@ -31,27 +31,27 @@ | @@ -31,27 +31,27 @@ | |||
31 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 31 | * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 32 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | 33 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | |
34 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 34 | * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | 35 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
36 | * THE POSSIBILITY OF SUCH DAMAGES. | 36 | * THE POSSIBILITY OF SUCH DAMAGES. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | #ifdef __FreeBSD__ | 40 | #ifdef __FreeBSD__ | |
41 | __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $"); | 41 | __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.104 2005/09/16 10:09:23 ru Exp $"); | |
42 | #endif | 42 | #endif | |
43 | #ifdef __NetBSD__ | 43 | #ifdef __NetBSD__ | |
44 | __KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.129 2019/12/17 04:54:36 christos Exp $"); | 44 | __KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.130 2020/01/29 14:09:58 thorpej Exp $"); | |
45 | #endif | 45 | #endif | |
46 | 46 | |||
47 | /* | 47 | /* | |
48 | * Driver for the Atheros Wireless LAN controller. | 48 | * Driver for the Atheros Wireless LAN controller. | |
49 | * | 49 | * | |
50 | * This software is derived from work of Atsushi Onoe; his contribution | 50 | * This software is derived from work of Atsushi Onoe; his contribution | |
51 | * is greatly appreciated. | 51 | * is greatly appreciated. | |
52 | */ | 52 | */ | |
53 | 53 | |||
54 | #ifdef _KERNEL_OPT | 54 | #ifdef _KERNEL_OPT | |
55 | #include "opt_inet.h" | 55 | #include "opt_inet.h" | |
56 | #endif | 56 | #endif | |
57 | 57 | |||
@@ -1390,27 +1390,27 @@ ath_start(struct ifnet *ifp) | @@ -1390,27 +1390,27 @@ ath_start(struct ifnet *ifp) | |||
1390 | * the frame back when the time is right. | 1390 | * the frame back when the time is right. | |
1391 | */ | 1391 | */ | |
1392 | ieee80211_pwrsave(ic, ni, m); | 1392 | ieee80211_pwrsave(ic, ni, m); | |
1393 | goto reclaim; | 1393 | goto reclaim; | |
1394 | } | 1394 | } | |
1395 | /* calculate priority so we can find the tx queue */ | 1395 | /* calculate priority so we can find the tx queue */ | |
1396 | if (ieee80211_classify(ic, m, ni)) { | 1396 | if (ieee80211_classify(ic, m, ni)) { | |
1397 | DPRINTF(sc, ATH_DEBUG_XMIT, | 1397 | DPRINTF(sc, ATH_DEBUG_XMIT, | |
1398 | "%s: discard, classification failure\n", | 1398 | "%s: discard, classification failure\n", | |
1399 | __func__); | 1399 | __func__); | |
1400 | m_freem(m); | 1400 | m_freem(m); | |
1401 | goto bad; | 1401 | goto bad; | |
1402 | } | 1402 | } | |
1403 | ifp->if_opackets++; | 1403 | if_statinc(ifp, if_opackets); | |
1404 | 1404 | |||
1405 | bpf_mtap(ifp, m, BPF_D_OUT); | 1405 | bpf_mtap(ifp, m, BPF_D_OUT); | |
1406 | /* | 1406 | /* | |
1407 | * Encapsulate the packet in prep for transmission. | 1407 | * Encapsulate the packet in prep for transmission. | |
1408 | */ | 1408 | */ | |
1409 | m = ieee80211_encap(ic, m, ni); | 1409 | m = ieee80211_encap(ic, m, ni); | |
1410 | if (m == NULL) { | 1410 | if (m == NULL) { | |
1411 | DPRINTF(sc, ATH_DEBUG_XMIT, | 1411 | DPRINTF(sc, ATH_DEBUG_XMIT, | |
1412 | "%s: encapsulation failure\n", | 1412 | "%s: encapsulation failure\n", | |
1413 | __func__); | 1413 | __func__); | |
1414 | sc->sc_stats.ast_tx_encap++; | 1414 | sc->sc_stats.ast_tx_encap++; | |
1415 | goto bad; | 1415 | goto bad; | |
1416 | } | 1416 | } | |
@@ -1452,27 +1452,27 @@ ath_start(struct ifnet *ifp) | @@ -1452,27 +1452,27 @@ ath_start(struct ifnet *ifp) | |||
1452 | /* XXX: adjust 100us delay to xmit */ | 1452 | /* XXX: adjust 100us delay to xmit */ | |
1453 | tsf += 100; | 1453 | tsf += 100; | |
1454 | tstamp = (u_int32_t *)&wh[1]; | 1454 | tstamp = (u_int32_t *)&wh[1]; | |
1455 | tstamp[0] = htole32(tsf & 0xffffffff); | 1455 | tstamp[0] = htole32(tsf & 0xffffffff); | |
1456 | tstamp[1] = htole32(tsf >> 32); | 1456 | tstamp[1] = htole32(tsf >> 32); | |
1457 | } | 1457 | } | |
1458 | sc->sc_stats.ast_tx_mgmt++; | 1458 | sc->sc_stats.ast_tx_mgmt++; | |
1459 | } | 1459 | } | |
1460 | 1460 | |||
1461 | nextfrag: | 1461 | nextfrag: | |
1462 | next = m->m_nextpkt; | 1462 | next = m->m_nextpkt; | |
1463 | if (ath_tx_start(sc, ni, bf, m)) { | 1463 | if (ath_tx_start(sc, ni, bf, m)) { | |
1464 | bad: | 1464 | bad: | |
1465 | ifp->if_oerrors++; | 1465 | if_statinc(ifp, if_oerrors); | |
1466 | reclaim: | 1466 | reclaim: | |
1467 | ATH_TXBUF_LOCK(sc); | 1467 | ATH_TXBUF_LOCK(sc); | |
1468 | STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); | 1468 | STAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); | |
1469 | ath_txfrag_cleanup(sc, &frags, ni); | 1469 | ath_txfrag_cleanup(sc, &frags, ni); | |
1470 | ATH_TXBUF_UNLOCK(sc); | 1470 | ATH_TXBUF_UNLOCK(sc); | |
1471 | if (ni != NULL) | 1471 | if (ni != NULL) | |
1472 | ieee80211_free_node(ni); | 1472 | ieee80211_free_node(ni); | |
1473 | continue; | 1473 | continue; | |
1474 | } | 1474 | } | |
1475 | if (next != NULL) { | 1475 | if (next != NULL) { | |
1476 | m = next; | 1476 | m = next; | |
1477 | bf = STAILQ_FIRST(&frags); | 1477 | bf = STAILQ_FIRST(&frags); | |
1478 | KASSERTMSG(bf != NULL, "no buf for txfrag"); | 1478 | KASSERTMSG(bf != NULL, "no buf for txfrag"); | |
@@ -3156,27 +3156,27 @@ ath_rx_proc(void *arg, int npending) | @@ -3156,27 +3156,27 @@ ath_rx_proc(void *arg, int npending) | |||
3156 | /* XXX frag's and qos frames */ | 3156 | /* XXX frag's and qos frames */ | |
3157 | len = ds->ds_rxstat.rs_datalen; | 3157 | len = ds->ds_rxstat.rs_datalen; | |
3158 | if (len >= sizeof (struct ieee80211_frame)) { | 3158 | if (len >= sizeof (struct ieee80211_frame)) { | |
3159 | bus_dmamap_sync(sc->sc_dmat, | 3159 | bus_dmamap_sync(sc->sc_dmat, | |
3160 | bf->bf_dmamap, | 3160 | bf->bf_dmamap, | |
3161 | 0, bf->bf_dmamap->dm_mapsize, | 3161 | 0, bf->bf_dmamap->dm_mapsize, | |
3162 | BUS_DMASYNC_POSTREAD); | 3162 | BUS_DMASYNC_POSTREAD); | |
3163 | ath_handle_micerror(ic, | 3163 | ath_handle_micerror(ic, | |
3164 | mtod(m, struct ieee80211_frame *), | 3164 | mtod(m, struct ieee80211_frame *), | |
3165 | sc->sc_splitmic ? | 3165 | sc->sc_splitmic ? | |
3166 | ds->ds_rxstat.rs_keyix-32 : ds->ds_rxstat.rs_keyix); | 3166 | ds->ds_rxstat.rs_keyix-32 : ds->ds_rxstat.rs_keyix); | |
3167 | } | 3167 | } | |
3168 | } | 3168 | } | |
3169 | ifp->if_ierrors++; | 3169 | if_statinc(ifp, if_ierrors); | |
3170 | /* | 3170 | /* | |
3171 | * Reject error frames, we normally don't want | 3171 | * Reject error frames, we normally don't want | |
3172 | * to see them in monitor mode (in monitor mode | 3172 | * to see them in monitor mode (in monitor mode | |
3173 | * allow through packets that have crypto problems). | 3173 | * allow through packets that have crypto problems). | |
3174 | */ | 3174 | */ | |
3175 | 3175 | |||
3176 | if (ds->ds_rxstat.rs_status &~ (rxerr_tap|rxerr_mon)) | 3176 | if (ds->ds_rxstat.rs_status &~ (rxerr_tap|rxerr_mon)) | |
3177 | goto rx_next; | 3177 | goto rx_next; | |
3178 | } | 3178 | } | |
3179 | rx_accept: | 3179 | rx_accept: | |
3180 | /* | 3180 | /* | |
3181 | * Sync and unmap the frame. At this point we're | 3181 | * Sync and unmap the frame. At this point we're | |
3182 | * committed to passing the mbuf somewhere so clear | 3182 | * committed to passing the mbuf somewhere so clear | |
@@ -5284,27 +5284,27 @@ ath_watchdog(struct ifnet *ifp) | @@ -5284,27 +5284,27 @@ ath_watchdog(struct ifnet *ifp) | |||
5284 | if (!ATH_TXQ_SETUP(sc, i)) | 5284 | if (!ATH_TXQ_SETUP(sc, i)) | |
5285 | continue; | 5285 | continue; | |
5286 | axq = &sc->sc_txq[i]; | 5286 | axq = &sc->sc_txq[i]; | |
5287 | ATH_TXQ_LOCK(axq); | 5287 | ATH_TXQ_LOCK(axq); | |
5288 | if (axq->axq_timer == 0) | 5288 | if (axq->axq_timer == 0) | |
5289 | ; | 5289 | ; | |
5290 | else if (--axq->axq_timer == 0) { | 5290 | else if (--axq->axq_timer == 0) { | |
5291 | ATH_TXQ_UNLOCK(axq); | 5291 | ATH_TXQ_UNLOCK(axq); | |
5292 | if_printf(ifp, "device timeout (txq %d, " | 5292 | if_printf(ifp, "device timeout (txq %d, " | |
5293 | "txintrperiod %d)\n", i, sc->sc_txintrperiod); | 5293 | "txintrperiod %d)\n", i, sc->sc_txintrperiod); | |
5294 | if (sc->sc_txintrperiod > 1) | 5294 | if (sc->sc_txintrperiod > 1) | |
5295 | sc->sc_txintrperiod--; | 5295 | sc->sc_txintrperiod--; | |
5296 | ath_reset(ifp); | 5296 | ath_reset(ifp); | |
5297 | ifp->if_oerrors++; | 5297 | if_statinc(ifp, if_oerrors); | |
5298 | sc->sc_stats.ast_watchdog++; | 5298 | sc->sc_stats.ast_watchdog++; | |
5299 | break; | 5299 | break; | |
5300 | } else | 5300 | } else | |
5301 | ifp->if_timer = 1; | 5301 | ifp->if_timer = 1; | |
5302 | ATH_TXQ_UNLOCK(axq); | 5302 | ATH_TXQ_UNLOCK(axq); | |
5303 | } | 5303 | } | |
5304 | ieee80211_watchdog(ic); | 5304 | ieee80211_watchdog(ic); | |
5305 | } | 5305 | } | |
5306 | 5306 | |||
5307 | /* | 5307 | /* | |
5308 | * Diagnostic interface to the HAL. This is used by various | 5308 | * Diagnostic interface to the HAL. This is used by various | |
5309 | * tools to do things like retrieve register contents for | 5309 | * tools to do things like retrieve register contents for | |
5310 | * debugging. The mechanism is intentionally opaque so that | 5310 | * debugging. The mechanism is intentionally opaque so that | |
@@ -5398,40 +5398,44 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, | @@ -5398,40 +5398,44 @@ ath_ioctl(struct ifnet *ifp, u_long cmd, | |||
5398 | break; | 5398 | break; | |
5399 | case 0: | 5399 | case 0: | |
5400 | break; | 5400 | break; | |
5401 | } | 5401 | } | |
5402 | break; | 5402 | break; | |
5403 | case SIOCADDMULTI: | 5403 | case SIOCADDMULTI: | |
5404 | case SIOCDELMULTI: | 5404 | case SIOCDELMULTI: | |
5405 | if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) { | 5405 | if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) { | |
5406 | if (ifp->if_flags & IFF_RUNNING) | 5406 | if (ifp->if_flags & IFF_RUNNING) | |
5407 | ath_mode_init(sc); | 5407 | ath_mode_init(sc); | |
5408 | error = 0; | 5408 | error = 0; | |
5409 | } | 5409 | } | |
5410 | break; | 5410 | break; | |
5411 | case SIOCGATHSTATS: | 5411 | case SIOCGATHSTATS: { | |
5412 | struct ath_stats stats_out; | |||
5413 | struct if_data ifi; | |||
5414 | ||||
5412 | /* NB: embed these numbers to get a consistent view */ | 5415 | /* NB: embed these numbers to get a consistent view */ | |
5413 | sc->sc_stats.ast_tx_packets = ifp->if_opackets; | 5416 | ||
5414 | sc->sc_stats.ast_rx_packets = ifp->if_ipackets; | 5417 | stats_out = sc->sc_stats; | |
5415 | sc->sc_stats.ast_rx_rssi = ieee80211_getrssi(ic); | 5418 | stats_out.ast_rx_rssi = ieee80211_getrssi(ic); | |
5416 | splx(s); | 5419 | splx(s); | |
5417 | /* | 5420 | ||
5418 | * NB: Drop the softc lock in case of a page fault; | 5421 | if_export_if_data(ifp, &ifi, false); | |
5419 | * we'll accept any potential inconsisentcy in the | 5422 | stats_out.ast_tx_packets = ifi.ifi_opackets; | |
5420 | * statistics. The alternative is to copy the data | 5423 | stats_out.ast_rx_packets = ifi.ifi_ipackets; | |
5421 | * to a local structure. | 5424 | ||
5422 | */ | 5425 | return copyout(&stats_out, | |
5423 | return copyout(&sc->sc_stats, | 5426 | ifr->ifr_data, sizeof (stats_out)); | |
5424 | ifr->ifr_data, sizeof (sc->sc_stats)); | 5427 | } | |
5428 | ||||
5425 | case SIOCGATHDIAG: | 5429 | case SIOCGATHDIAG: | |
5426 | error = kauth_authorize_network(curlwp->l_cred, | 5430 | error = kauth_authorize_network(curlwp->l_cred, | |
5427 | KAUTH_NETWORK_INTERFACE, | 5431 | KAUTH_NETWORK_INTERFACE, | |
5428 | KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, KAUTH_ARG(cmd), | 5432 | KAUTH_REQ_NETWORK_INTERFACE_SETPRIV, ifp, KAUTH_ARG(cmd), | |
5429 | NULL); | 5433 | NULL); | |
5430 | if (error) | 5434 | if (error) | |
5431 | break; | 5435 | break; | |
5432 | error = ath_ioctl_diag(sc, (struct ath_diag *) ifr); | 5436 | error = ath_ioctl_diag(sc, (struct ath_diag *) ifr); | |
5433 | break; | 5437 | break; | |
5434 | default: | 5438 | default: | |
5435 | error = ieee80211_ioctl(ic, cmd, data); | 5439 | error = ieee80211_ioctl(ic, cmd, data); | |
5436 | if (error != ENETRESET) | 5440 | if (error != ENETRESET) | |
5437 | ; | 5441 | ; |
--- src/sys/dev/ic/athn.c 2019/07/25 11:56:09 1.22
+++ src/sys/dev/ic/athn.c 2020/01/29 14:09:58 1.23
@@ -1,39 +1,39 @@ | @@ -1,39 +1,39 @@ | |||
1 | /* $NetBSD: athn.c,v 1.22 2019/07/25 11:56:09 msaitoh Exp $ */ | 1 | /* $NetBSD: athn.c,v 1.23 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | /* $OpenBSD: athn.c,v 1.83 2014/07/22 13:12:11 mpi Exp $ */ | 2 | /* $OpenBSD: athn.c,v 1.83 2014/07/22 13:12:11 mpi Exp $ */ | |
3 | 3 | |||
4 | /*- | 4 | /*- | |
5 | * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> | 5 | * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> | |
6 | * Copyright (c) 2008-2010 Atheros Communications Inc. | 6 | * Copyright (c) 2008-2010 Atheros Communications Inc. | |
7 | * | 7 | * | |
8 | * Permission to use, copy, modify, and/or distribute this software for any | 8 | * Permission to use, copy, modify, and/or 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 Atheros 802.11a/g/n chipsets. | 22 | * Driver for Atheros 802.11a/g/n chipsets. | |
23 | */ | 23 | */ | |
24 | 24 | |||
25 | #include <sys/cdefs.h> | 25 | #include <sys/cdefs.h> | |
26 | __KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.22 2019/07/25 11:56:09 msaitoh Exp $"); | 26 | __KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.23 2020/01/29 14:09:58 thorpej Exp $"); | |
27 | 27 | |||
28 | #ifndef _MODULE | 28 | #ifndef _MODULE | |
29 | #include "athn_usb.h" /* for NATHN_USB */ | 29 | #include "athn_usb.h" /* for NATHN_USB */ | |
30 | #endif | 30 | #endif | |
31 | 31 | |||
32 | #include <sys/param.h> | 32 | #include <sys/param.h> | |
33 | #include <sys/sockio.h> | 33 | #include <sys/sockio.h> | |
34 | #include <sys/mbuf.h> | 34 | #include <sys/mbuf.h> | |
35 | #include <sys/kernel.h> | 35 | #include <sys/kernel.h> | |
36 | #include <sys/socket.h> | 36 | #include <sys/socket.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/malloc.h> | 38 | #include <sys/malloc.h> | |
39 | #include <sys/queue.h> | 39 | #include <sys/queue.h> | |
@@ -2661,69 +2661,69 @@ athn_start(struct ifnet *ifp) | @@ -2661,69 +2661,69 @@ athn_start(struct ifnet *ifp) | |||
2661 | ni = M_GETCTX(m, struct ieee80211_node *); | 2661 | ni = M_GETCTX(m, struct ieee80211_node *); | |
2662 | goto sendit; | 2662 | goto sendit; | |
2663 | } | 2663 | } | |
2664 | if (ic->ic_state != IEEE80211_S_RUN) | 2664 | if (ic->ic_state != IEEE80211_S_RUN) | |
2665 | break; | 2665 | break; | |
2666 | 2666 | |||
2667 | /* Encapsulate and send data frames. */ | 2667 | /* Encapsulate and send data frames. */ | |
2668 | IFQ_DEQUEUE(&ifp->if_snd, m); | 2668 | IFQ_DEQUEUE(&ifp->if_snd, m); | |
2669 | if (m == NULL) | 2669 | if (m == NULL) | |
2670 | break; | 2670 | break; | |
2671 | 2671 | |||
2672 | if (m->m_len < (int)sizeof(*eh) && | 2672 | if (m->m_len < (int)sizeof(*eh) && | |
2673 | (m = m_pullup(m, sizeof(*eh))) == NULL) { | 2673 | (m = m_pullup(m, sizeof(*eh))) == NULL) { | |
2674 | ifp->if_oerrors++; | 2674 | if_statinc(ifp, if_oerrors); | |
2675 | continue; | 2675 | continue; | |
2676 | } | 2676 | } | |
2677 | eh = mtod(m, struct ether_header *); | 2677 | eh = mtod(m, struct ether_header *); | |
2678 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | 2678 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | |
2679 | if (ni == NULL) { | 2679 | if (ni == NULL) { | |
2680 | m_freem(m); | 2680 | m_freem(m); | |
2681 | ifp->if_oerrors++; | 2681 | if_statinc(ifp, if_oerrors); | |
2682 | continue; | 2682 | continue; | |
2683 | } | 2683 | } | |
2684 | 2684 | |||
2685 | bpf_mtap(ifp, m, BPF_D_OUT); | 2685 | bpf_mtap(ifp, m, BPF_D_OUT); | |
2686 | 2686 | |||
2687 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) | 2687 | if ((m = ieee80211_encap(ic, m, ni)) == NULL) | |
2688 | continue; | 2688 | continue; | |
2689 | sendit: | 2689 | sendit: | |
2690 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | 2690 | bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); | |
2691 | 2691 | |||
2692 | if (sc->sc_ops.tx(sc, m, ni, 0) != 0) { | 2692 | if (sc->sc_ops.tx(sc, m, ni, 0) != 0) { | |
2693 | ieee80211_free_node(ni); | 2693 | ieee80211_free_node(ni); | |
2694 | ifp->if_oerrors++; | 2694 | if_statinc(ifp, if_oerrors); | |
2695 | continue; | 2695 | continue; | |
2696 | } | 2696 | } | |
2697 | 2697 | |||
2698 | sc->sc_tx_timer = 5; | 2698 | sc->sc_tx_timer = 5; | |
2699 | ifp->if_timer = 1; | 2699 | ifp->if_timer = 1; | |
2700 | } | 2700 | } | |
2701 | } | 2701 | } | |
2702 | 2702 | |||
2703 | Static void | 2703 | Static void | |
2704 | athn_watchdog(struct ifnet *ifp) | 2704 | athn_watchdog(struct ifnet *ifp) | |
2705 | { | 2705 | { | |
2706 | struct athn_softc *sc = ifp->if_softc; | 2706 | struct athn_softc *sc = ifp->if_softc; | |
2707 | 2707 | |||
2708 | ifp->if_timer = 0; | 2708 | ifp->if_timer = 0; | |
2709 | 2709 | |||
2710 | if (sc->sc_tx_timer > 0) { | 2710 | if (sc->sc_tx_timer > 0) { | |
2711 | if (--sc->sc_tx_timer == 0) { | 2711 | if (--sc->sc_tx_timer == 0) { | |
2712 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | 2712 | aprint_error_dev(sc->sc_dev, "device timeout\n"); | |
2713 | /* see athn_init, no need to call athn_stop here */ | 2713 | /* see athn_init, no need to call athn_stop here */ | |
2714 | /* athn_stop(ifp, 0); */ | 2714 | /* athn_stop(ifp, 0); */ | |
2715 | (void)athn_init(ifp); | 2715 | (void)athn_init(ifp); | |
2716 | ifp->if_oerrors++; | 2716 | if_statinc(ifp, if_oerrors); | |
2717 | return; | 2717 | return; | |
2718 | } | 2718 | } | |
2719 | ifp->if_timer = 1; | 2719 | ifp->if_timer = 1; | |
2720 | } | 2720 | } | |
2721 | ieee80211_watchdog(&sc->sc_ic); | 2721 | ieee80211_watchdog(&sc->sc_ic); | |
2722 | } | 2722 | } | |
2723 | 2723 | |||
2724 | Static void | 2724 | Static void | |
2725 | athn_set_multi(struct athn_softc *sc) | 2725 | athn_set_multi(struct athn_softc *sc) | |
2726 | { | 2726 | { | |
2727 | struct ethercom *ec = &sc->sc_ec; | 2727 | struct ethercom *ec = &sc->sc_ec; | |
2728 | struct ifnet *ifp = &ec->ec_if; | 2728 | struct ifnet *ifp = &ec->ec_if; | |
2729 | struct ether_multi *enm; | 2729 | struct ether_multi *enm; |
--- src/sys/dev/ic/atw.c 2019/11/10 21:16:35 1.169
+++ src/sys/dev/ic/atw.c 2020/01/29 14:09:58 1.170
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: atw.c,v 1.169 2019/11/10 21:16:35 chs Exp $ */ | 1 | /* $NetBSD: atw.c,v 1.170 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by David Young, by Jason R. Thorpe, and by Charles M. Hannum. | 8 | * by David Young, by Jason R. Thorpe, and by Charles M. Hannum. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -24,27 +24,27 @@ | @@ -24,27 +24,27 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Device driver for the ADMtek ADM8211 802.11 MAC/BBP. | 33 | * Device driver for the ADMtek ADM8211 802.11 MAC/BBP. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.169 2019/11/10 21:16:35 chs Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: atw.c,v 1.170 2020/01/29 14:09:58 thorpej Exp $"); | |
38 | 38 | |||
39 | 39 | |||
40 | #include <sys/param.h> | 40 | #include <sys/param.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/callout.h> | 42 | #include <sys/callout.h> | |
43 | #include <sys/mbuf.h> | 43 | #include <sys/mbuf.h> | |
44 | #include <sys/malloc.h> | 44 | #include <sys/malloc.h> | |
45 | #include <sys/kernel.h> | 45 | #include <sys/kernel.h> | |
46 | #include <sys/socket.h> | 46 | #include <sys/socket.h> | |
47 | #include <sys/ioctl.h> | 47 | #include <sys/ioctl.h> | |
48 | #include <sys/errno.h> | 48 | #include <sys/errno.h> | |
49 | #include <sys/device.h> | 49 | #include <sys/device.h> | |
50 | #include <sys/kauth.h> | 50 | #include <sys/kauth.h> | |
@@ -3143,27 +3143,27 @@ atw_rxintr(struct atw_softc *sc) | @@ -3143,27 +3143,27 @@ atw_rxintr(struct atw_softc *sc) | |||
3143 | return; | 3143 | return; | |
3144 | } | 3144 | } | |
3145 | 3145 | |||
3146 | /* | 3146 | /* | |
3147 | * If an error occurred, update stats, clear the status | 3147 | * If an error occurred, update stats, clear the status | |
3148 | * word, and leave the packet buffer in place. It will | 3148 | * word, and leave the packet buffer in place. It will | |
3149 | * simply be reused the next time the ring comes around. | 3149 | * simply be reused the next time the ring comes around. | |
3150 | */ | 3150 | */ | |
3151 | if ((rxstat & (ATW_RXSTAT_DE | ATW_RXSTAT_RXTOE)) != 0) { | 3151 | if ((rxstat & (ATW_RXSTAT_DE | ATW_RXSTAT_RXTOE)) != 0) { | |
3152 | #define PRINTERR(bit, str) \ | 3152 | #define PRINTERR(bit, str) \ | |
3153 | if (rxstat & (bit)) \ | 3153 | if (rxstat & (bit)) \ | |
3154 | aprint_error_dev(sc->sc_dev, "receive error: %s\n", \ | 3154 | aprint_error_dev(sc->sc_dev, "receive error: %s\n", \ | |
3155 | str) | 3155 | str) | |
3156 | ifp->if_ierrors++; | 3156 | if_statinc(ifp, if_ierrors); | |
3157 | PRINTERR(ATW_RXSTAT_DE, "descriptor error"); | 3157 | PRINTERR(ATW_RXSTAT_DE, "descriptor error"); | |
3158 | PRINTERR(ATW_RXSTAT_RXTOE, "time-out"); | 3158 | PRINTERR(ATW_RXSTAT_RXTOE, "time-out"); | |
3159 | #if 0 | 3159 | #if 0 | |
3160 | PRINTERR(ATW_RXSTAT_SFDE, "PLCP SFD error"); | 3160 | PRINTERR(ATW_RXSTAT_SFDE, "PLCP SFD error"); | |
3161 | PRINTERR(ATW_RXSTAT_SIGE, "PLCP signal error"); | 3161 | PRINTERR(ATW_RXSTAT_SIGE, "PLCP signal error"); | |
3162 | PRINTERR(ATW_RXSTAT_CRC16E, "PLCP CRC16 error"); | 3162 | PRINTERR(ATW_RXSTAT_CRC16E, "PLCP CRC16 error"); | |
3163 | PRINTERR(ATW_RXSTAT_ICVE, "WEP ICV error"); | 3163 | PRINTERR(ATW_RXSTAT_ICVE, "WEP ICV error"); | |
3164 | #endif | 3164 | #endif | |
3165 | #undef PRINTERR | 3165 | #undef PRINTERR | |
3166 | atw_init_rxdesc(sc, i); | 3166 | atw_init_rxdesc(sc, i); | |
3167 | continue; | 3167 | continue; | |
3168 | } | 3168 | } | |
3169 | 3169 | |||
@@ -3173,34 +3173,34 @@ atw_rxintr(struct atw_softc *sc) | @@ -3173,34 +3173,34 @@ atw_rxintr(struct atw_softc *sc) | |||
3173 | /* | 3173 | /* | |
3174 | * No errors; receive the packet. Note the ADM8211 | 3174 | * No errors; receive the packet. Note the ADM8211 | |
3175 | * includes the CRC in promiscuous mode. | 3175 | * includes the CRC in promiscuous mode. | |
3176 | */ | 3176 | */ | |
3177 | len = __SHIFTOUT(rxstat, ATW_RXSTAT_FL_MASK); | 3177 | len = __SHIFTOUT(rxstat, ATW_RXSTAT_FL_MASK); | |
3178 | 3178 | |||
3179 | /* | 3179 | /* | |
3180 | * Allocate a new mbuf cluster. If that fails, we are | 3180 | * Allocate a new mbuf cluster. If that fails, we are | |
3181 | * out of memory, and must drop the packet and recycle | 3181 | * out of memory, and must drop the packet and recycle | |
3182 | * the buffer that's already attached to this descriptor. | 3182 | * the buffer that's already attached to this descriptor. | |
3183 | */ | 3183 | */ | |
3184 | m = rxs->rxs_mbuf; | 3184 | m = rxs->rxs_mbuf; | |
3185 | if (atw_add_rxbuf(sc, i) != 0) { | 3185 | if (atw_add_rxbuf(sc, i) != 0) { | |
3186 | ifp->if_ierrors++; | 3186 | if_statinc(ifp, if_ierrors); | |
3187 | bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0, | 3187 | bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0, | |
3188 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | 3188 | rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_PREREAD); | |
3189 | atw_init_rxdesc(sc, i); | 3189 | atw_init_rxdesc(sc, i); | |
3190 | continue; | 3190 | continue; | |
3191 | } | 3191 | } | |
3192 | 3192 | |||
3193 | ifp->if_ipackets++; | 3193 | if_statinc(ifp, if_ipackets); | |
3194 | m_set_rcvif(m, ifp); | 3194 | m_set_rcvif(m, ifp); | |
3195 | m->m_pkthdr.len = m->m_len = MIN(m->m_ext.ext_size, len); | 3195 | m->m_pkthdr.len = m->m_len = MIN(m->m_ext.ext_size, len); | |
3196 | 3196 | |||
3197 | rate = (rate0 < __arraycount(rate_tbl)) ? rate_tbl[rate0] : 0; | 3197 | rate = (rate0 < __arraycount(rate_tbl)) ? rate_tbl[rate0] : 0; | |
3198 | 3198 | |||
3199 | /* The RSSI comes straight from a register in the | 3199 | /* The RSSI comes straight from a register in the | |
3200 | * baseband processor. I know that for the RF3000, | 3200 | * baseband processor. I know that for the RF3000, | |
3201 | * the RSSI register also contains the antenna-selection | 3201 | * the RSSI register also contains the antenna-selection | |
3202 | * bits. Mask those off. | 3202 | * bits. Mask those off. | |
3203 | * | 3203 | * | |
3204 | * TBD Treat other basebands. | 3204 | * TBD Treat other basebands. | |
3205 | * TBD Use short-preamble bit and such in RF3000_RXSTAT. | 3205 | * TBD Use short-preamble bit and such in RF3000_RXSTAT. | |
3206 | */ | 3206 | */ | |
@@ -3236,27 +3236,27 @@ atw_rxintr(struct atw_softc *sc) | @@ -3236,27 +3236,27 @@ atw_rxintr(struct atw_softc *sc) | |||
3236 | if ((rxstat & (ATW_RXSTAT_CRC16E | ATW_RXSTAT_CRC32E | | 3236 | if ((rxstat & (ATW_RXSTAT_CRC16E | ATW_RXSTAT_CRC32E | | |
3237 | ATW_RXSTAT_ICVE | ATW_RXSTAT_SFDE | ATW_RXSTAT_SIGE)) | 3237 | ATW_RXSTAT_ICVE | ATW_RXSTAT_SFDE | ATW_RXSTAT_SIGE)) | |
3238 | != 0) { | 3238 | != 0) { | |
3239 | if (rxstat & ATW_RXSTAT_CRC16E) | 3239 | if (rxstat & ATW_RXSTAT_CRC16E) | |
3240 | sc->sc_crc16e_ev.ev_count++; | 3240 | sc->sc_crc16e_ev.ev_count++; | |
3241 | if (rxstat & ATW_RXSTAT_CRC32E) | 3241 | if (rxstat & ATW_RXSTAT_CRC32E) | |
3242 | sc->sc_crc32e_ev.ev_count++; | 3242 | sc->sc_crc32e_ev.ev_count++; | |
3243 | if (rxstat & ATW_RXSTAT_ICVE) | 3243 | if (rxstat & ATW_RXSTAT_ICVE) | |
3244 | sc->sc_icve_ev.ev_count++; | 3244 | sc->sc_icve_ev.ev_count++; | |
3245 | if (rxstat & ATW_RXSTAT_SFDE) | 3245 | if (rxstat & ATW_RXSTAT_SFDE) | |
3246 | sc->sc_sfde_ev.ev_count++; | 3246 | sc->sc_sfde_ev.ev_count++; | |
3247 | if (rxstat & ATW_RXSTAT_SIGE) | 3247 | if (rxstat & ATW_RXSTAT_SIGE) | |
3248 | sc->sc_sige_ev.ev_count++; | 3248 | sc->sc_sige_ev.ev_count++; | |
3249 | ifp->if_ierrors++; | 3249 | if_statinc(ifp, if_ierrors); | |
3250 | m_freem(m); | 3250 | m_freem(m); | |
3251 | splx(s); | 3251 | splx(s); | |
3252 | continue; | 3252 | continue; | |
3253 | } | 3253 | } | |
3254 | 3254 | |||
3255 | if (sc->sc_opmode & ATW_NAR_PR) | 3255 | if (sc->sc_opmode & ATW_NAR_PR) | |
3256 | m_adj(m, -IEEE80211_CRC_LEN); | 3256 | m_adj(m, -IEEE80211_CRC_LEN); | |
3257 | 3257 | |||
3258 | wh = mtod(m, struct ieee80211_frame_min *); | 3258 | wh = mtod(m, struct ieee80211_frame_min *); | |
3259 | ni = ieee80211_find_rxnode(ic, wh); | 3259 | ni = ieee80211_find_rxnode(ic, wh); | |
3260 | #if 0 | 3260 | #if 0 | |
3261 | if (atw_hw_decrypted(sc, wh)) { | 3261 | if (atw_hw_decrypted(sc, wh)) { | |
3262 | wh->i_fc[1] &= ~IEEE80211_FC1_WEP; | 3262 | wh->i_fc[1] &= ~IEEE80211_FC1_WEP; | |
@@ -3360,32 +3360,32 @@ atw_txintr(struct atw_softc *sc, uint32_ | @@ -3360,32 +3360,32 @@ atw_txintr(struct atw_softc *sc, uint32_ | |||
3360 | */ | 3360 | */ | |
3361 | if (txstat & ATW_TXSTAT_TUF) | 3361 | if (txstat & ATW_TXSTAT_TUF) | |
3362 | sc->sc_tuf_ev.ev_count++; | 3362 | sc->sc_tuf_ev.ev_count++; | |
3363 | if (txstat & ATW_TXSTAT_TLT) | 3363 | if (txstat & ATW_TXSTAT_TLT) | |
3364 | sc->sc_tlt_ev.ev_count++; | 3364 | sc->sc_tlt_ev.ev_count++; | |
3365 | if (txstat & ATW_TXSTAT_TRT) | 3365 | if (txstat & ATW_TXSTAT_TRT) | |
3366 | sc->sc_trt_ev.ev_count++; | 3366 | sc->sc_trt_ev.ev_count++; | |
3367 | if (txstat & ATW_TXSTAT_TRO) | 3367 | if (txstat & ATW_TXSTAT_TRO) | |
3368 | sc->sc_tro_ev.ev_count++; | 3368 | sc->sc_tro_ev.ev_count++; | |
3369 | if (txstat & ATW_TXSTAT_SOFBR) | 3369 | if (txstat & ATW_TXSTAT_SOFBR) | |
3370 | sc->sc_sofbr_ev.ev_count++; | 3370 | sc->sc_sofbr_ev.ev_count++; | |
3371 | 3371 | |||
3372 | if ((txstat & ATW_TXSTAT_ES) == 0) | 3372 | if ((txstat & ATW_TXSTAT_ES) == 0) | |
3373 | ifp->if_collisions += | 3373 | if_statadd(ifp, if_collisions, | |
3374 | __SHIFTOUT(txstat, ATW_TXSTAT_ARC_MASK); | 3374 | __SHIFTOUT(txstat, ATW_TXSTAT_ARC_MASK)); | |
3375 | else | 3375 | else | |
3376 | ifp->if_oerrors++; | 3376 | if_statinc(ifp, if_oerrors); | |
3377 | 3377 | |||
3378 | ifp->if_opackets++; | 3378 | if_statinc(ifp, if_opackets); | |
3379 | } | 3379 | } | |
3380 | 3380 | |||
3381 | KASSERT(txs != NULL || (ifp->if_flags & IFF_OACTIVE) == 0); | 3381 | KASSERT(txs != NULL || (ifp->if_flags & IFF_OACTIVE) == 0); | |
3382 | 3382 | |||
3383 | splx(s); | 3383 | splx(s); | |
3384 | } | 3384 | } | |
3385 | 3385 | |||
3386 | /* | 3386 | /* | |
3387 | * atw_watchdog: [ifnet interface function] | 3387 | * atw_watchdog: [ifnet interface function] | |
3388 | * | 3388 | * | |
3389 | * Watchdog timer handler. | 3389 | * Watchdog timer handler. | |
3390 | */ | 3390 | */ | |
3391 | void | 3391 | void | |
@@ -3393,27 +3393,27 @@ atw_watchdog(struct ifnet *ifp) | @@ -3393,27 +3393,27 @@ atw_watchdog(struct ifnet *ifp) | |||
3393 | { | 3393 | { | |
3394 | struct atw_softc *sc = ifp->if_softc; | 3394 | struct atw_softc *sc = ifp->if_softc; | |
3395 | struct ieee80211com *ic = &sc->sc_ic; | 3395 | struct ieee80211com *ic = &sc->sc_ic; | |
3396 | 3396 | |||
3397 | ifp->if_timer = 0; | 3397 | ifp->if_timer = 0; | |
3398 | if (!device_is_active(sc->sc_dev)) | 3398 | if (!device_is_active(sc->sc_dev)) | |
3399 | return; | 3399 | return; | |
3400 | 3400 | |||
3401 | if (sc->sc_rescan_timer != 0 && --sc->sc_rescan_timer == 0) | 3401 | if (sc->sc_rescan_timer != 0 && --sc->sc_rescan_timer == 0) | |
3402 | (void)ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); | 3402 | (void)ieee80211_new_state(ic, IEEE80211_S_SCAN, -1); | |
3403 | if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0 && | 3403 | if (sc->sc_tx_timer != 0 && --sc->sc_tx_timer == 0 && | |
3404 | !SIMPLEQ_EMPTY(&sc->sc_txdirtyq)) { | 3404 | !SIMPLEQ_EMPTY(&sc->sc_txdirtyq)) { | |
3405 | printf("%s: transmit timeout\n", ifp->if_xname); | 3405 | printf("%s: transmit timeout\n", ifp->if_xname); | |
3406 | ifp->if_oerrors++; | 3406 | if_statinc(ifp, if_oerrors); | |
3407 | (void)atw_init(ifp); | 3407 | (void)atw_init(ifp); | |
3408 | atw_start(ifp); | 3408 | atw_start(ifp); | |
3409 | } | 3409 | } | |
3410 | if (sc->sc_tx_timer != 0 || sc->sc_rescan_timer != 0) | 3410 | if (sc->sc_tx_timer != 0 || sc->sc_rescan_timer != 0) | |
3411 | ifp->if_timer = 1; | 3411 | ifp->if_timer = 1; | |
3412 | ieee80211_watchdog(ic); | 3412 | ieee80211_watchdog(ic); | |
3413 | } | 3413 | } | |
3414 | 3414 | |||
3415 | static void | 3415 | static void | |
3416 | atw_evcnt_detach(struct atw_softc *sc) | 3416 | atw_evcnt_detach(struct atw_softc *sc) | |
3417 | { | 3417 | { | |
3418 | evcnt_detach(&sc->sc_sige_ev); | 3418 | evcnt_detach(&sc->sc_sige_ev); | |
3419 | evcnt_detach(&sc->sc_sfde_ev); | 3419 | evcnt_detach(&sc->sc_sfde_ev); | |
@@ -3556,46 +3556,46 @@ atw_start(struct ifnet *ifp) | @@ -3556,46 +3556,46 @@ atw_start(struct ifnet *ifp) | |||
3556 | if (m0 != NULL) { | 3556 | if (m0 != NULL) { | |
3557 | ni = M_GETCTX(m0, struct ieee80211_node *); | 3557 | ni = M_GETCTX(m0, struct ieee80211_node *); | |
3558 | M_CLEARCTX(m0); | 3558 | M_CLEARCTX(m0); | |
3559 | } else if (ic->ic_state != IEEE80211_S_RUN) | 3559 | } else if (ic->ic_state != IEEE80211_S_RUN) | |
3560 | break; /* send no data until associated */ | 3560 | break; /* send no data until associated */ | |
3561 | else { | 3561 | else { | |
3562 | IFQ_DEQUEUE(&ifp->if_snd, m0); | 3562 | IFQ_DEQUEUE(&ifp->if_snd, m0); | |
3563 | if (m0 == NULL) | 3563 | if (m0 == NULL) | |
3564 | break; | 3564 | break; | |
3565 | bpf_mtap(ifp, m0, BPF_D_OUT); | 3565 | bpf_mtap(ifp, m0, BPF_D_OUT); | |
3566 | ni = ieee80211_find_txnode(ic, | 3566 | ni = ieee80211_find_txnode(ic, | |
3567 | mtod(m0, struct ether_header *)->ether_dhost); | 3567 | mtod(m0, struct ether_header *)->ether_dhost); | |
3568 | if (ni == NULL) { | 3568 | if (ni == NULL) { | |
3569 | ifp->if_oerrors++; | 3569 | if_statinc(ifp, if_oerrors); | |
3570 | break; | 3570 | break; | |
3571 | } | 3571 | } | |
3572 | if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) { | 3572 | if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) { | |
3573 | ieee80211_free_node(ni); | 3573 | ieee80211_free_node(ni); | |
3574 | ifp->if_oerrors++; | 3574 | if_statinc(ifp, if_oerrors); | |
3575 | break; | 3575 | break; | |
3576 | } | 3576 | } | |
3577 | } | 3577 | } | |
3578 | 3578 | |||
3579 | rate = MAX(ieee80211_get_rate(ni), 2); | 3579 | rate = MAX(ieee80211_get_rate(ni), 2); | |
3580 | 3580 | |||
3581 | whm = mtod(m0, struct ieee80211_frame_min *); | 3581 | whm = mtod(m0, struct ieee80211_frame_min *); | |
3582 | 3582 | |||
3583 | if ((whm->i_fc[1] & IEEE80211_FC1_WEP) == 0) | 3583 | if ((whm->i_fc[1] & IEEE80211_FC1_WEP) == 0) | |
3584 | k = NULL; | 3584 | k = NULL; | |
3585 | else if ((k = ieee80211_crypto_encap(ic, ni, m0)) == NULL) { | 3585 | else if ((k = ieee80211_crypto_encap(ic, ni, m0)) == NULL) { | |
3586 | m_freem(m0); | 3586 | m_freem(m0); | |
3587 | ieee80211_free_node(ni); | 3587 | ieee80211_free_node(ni); | |
3588 | ifp->if_oerrors++; | 3588 | if_statinc(ifp, if_oerrors); | |
3589 | break; | 3589 | break; | |
3590 | } | 3590 | } | |
3591 | #if 0 | 3591 | #if 0 | |
3592 | if (IEEE80211_IS_MULTICAST(wh->i_addr1) && | 3592 | if (IEEE80211_IS_MULTICAST(wh->i_addr1) && | |
3593 | m0->m_pkthdr.len > ic->ic_fragthreshold) | 3593 | m0->m_pkthdr.len > ic->ic_fragthreshold) | |
3594 | hdrctl |= htole16(ATW_HDRCTL_MORE_FRAG); | 3594 | hdrctl |= htole16(ATW_HDRCTL_MORE_FRAG); | |
3595 | #endif | 3595 | #endif | |
3596 | 3596 | |||
3597 | if (m0->m_pkthdr.len + IEEE80211_CRC_LEN >= ic->ic_rtsthreshold) | 3597 | if (m0->m_pkthdr.len + IEEE80211_CRC_LEN >= ic->ic_rtsthreshold) | |
3598 | hdrctl |= htole16(ATW_HDRCTL_RTSCTS); | 3598 | hdrctl |= htole16(ATW_HDRCTL_RTSCTS); | |
3599 | 3599 | |||
3600 | if (ieee80211_compute_duration(whm, k, m0->m_pkthdr.len, | 3600 | if (ieee80211_compute_duration(whm, k, m0->m_pkthdr.len, | |
3601 | ic->ic_flags, ic->ic_fragthreshold, rate, | 3601 | ic->ic_flags, ic->ic_fragthreshold, rate, | |
@@ -3620,35 +3620,35 @@ atw_start(struct ifnet *ifp) | @@ -3620,35 +3620,35 @@ atw_start(struct ifnet *ifp) | |||
3620 | 3620 | |||
3621 | tap->at_rate = rate; | 3621 | tap->at_rate = rate; | |
3622 | 3622 | |||
3623 | bpf_mtap2(sc->sc_radiobpf, tap, sizeof(sc->sc_txtapu), | 3623 | bpf_mtap2(sc->sc_radiobpf, tap, sizeof(sc->sc_txtapu), | |
3624 | m0, BPF_D_OUT); | 3624 | m0, BPF_D_OUT); | |
3625 | } | 3625 | } | |
3626 | 3626 | |||
3627 | M_PREPEND(m0, offsetof(struct atw_frame, atw_ihdr), M_DONTWAIT); | 3627 | M_PREPEND(m0, offsetof(struct atw_frame, atw_ihdr), M_DONTWAIT); | |
3628 | 3628 | |||
3629 | if (ni != NULL) | 3629 | if (ni != NULL) | |
3630 | ieee80211_free_node(ni); | 3630 | ieee80211_free_node(ni); | |
3631 | 3631 | |||
3632 | if (m0 == NULL) { | 3632 | if (m0 == NULL) { | |
3633 | ifp->if_oerrors++; | 3633 | if_statinc(ifp, if_oerrors); | |
3634 | break; | 3634 | break; | |
3635 | } | 3635 | } | |
3636 | 3636 | |||
3637 | /* just to make sure. */ | 3637 | /* just to make sure. */ | |
3638 | m0 = m_pullup(m0, sizeof(struct atw_frame)); | 3638 | m0 = m_pullup(m0, sizeof(struct atw_frame)); | |
3639 | 3639 | |||
3640 | if (m0 == NULL) { | 3640 | if (m0 == NULL) { | |
3641 | ifp->if_oerrors++; | 3641 | if_statinc(ifp, if_oerrors); | |
3642 | break; | 3642 | break; | |
3643 | } | 3643 | } | |
3644 | 3644 | |||
3645 | hh = mtod(m0, struct atw_frame *); | 3645 | hh = mtod(m0, struct atw_frame *); | |
3646 | wh = &hh->atw_ihdr; | 3646 | wh = &hh->atw_ihdr; | |
3647 | 3647 | |||
3648 | /* Copy everything we need from the 802.11 header: | 3648 | /* Copy everything we need from the 802.11 header: | |
3649 | * Frame Control; address 1, address 3, or addresses | 3649 | * Frame Control; address 1, address 3, or addresses | |
3650 | * 3 and 4. NIC fills in BSSID, SA. | 3650 | * 3 and 4. NIC fills in BSSID, SA. | |
3651 | */ | 3651 | */ | |
3652 | if (wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) { | 3652 | if (wh->i_fc[1] & IEEE80211_FC1_DIR_TODS) { | |
3653 | if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) | 3653 | if (wh->i_fc[1] & IEEE80211_FC1_DIR_FROMDS) | |
3654 | panic("%s: illegal WDS frame", | 3654 | panic("%s: illegal WDS frame", |
--- src/sys/dev/ic/awi.c 2019/12/05 03:11:40 1.99
+++ src/sys/dev/ic/awi.c 2020/01/29 14:09:58 1.100
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: awi.c,v 1.99 2019/12/05 03:11:40 msaitoh Exp $ */ | 1 | /* $NetBSD: awi.c,v 1.100 2020/01/29 14:09:58 thorpej Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1999,2000,2001 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Bill Sommerfeld | 8 | * by Bill Sommerfeld | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -68,27 +68,27 @@ | @@ -68,27 +68,27 @@ | |||
68 | */ | 68 | */ | |
69 | 69 | |||
70 | /* | 70 | /* | |
71 | * Driver for AMD 802.11 PCnetMobile firmware. | 71 | * Driver for AMD 802.11 PCnetMobile firmware. | |
72 | * Uses am79c930 chip driver to talk to firmware running on the am79c930. | 72 | * Uses am79c930 chip driver to talk to firmware running on the am79c930. | |
73 | * | 73 | * | |
74 | * The initial version of the driver was written by | 74 | * The initial version of the driver was written by | |
75 | * Bill Sommerfeld <sommerfeld@NetBSD.org>. | 75 | * Bill Sommerfeld <sommerfeld@NetBSD.org>. | |
76 | * Then the driver module completely rewritten to support cards with DS phy | 76 | * Then the driver module completely rewritten to support cards with DS phy | |
77 | * and to support adhoc mode by Atsushi Onoe <onoe@NetBSD.org> | 77 | * and to support adhoc mode by Atsushi Onoe <onoe@NetBSD.org> | |
78 | */ | 78 | */ | |
79 | 79 | |||
80 | #include <sys/cdefs.h> | 80 | #include <sys/cdefs.h> | |
81 | __KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.99 2019/12/05 03:11:40 msaitoh Exp $"); | 81 | __KERNEL_RCSID(0, "$NetBSD: awi.c,v 1.100 2020/01/29 14:09:58 thorpej Exp $"); | |
82 | 82 | |||
83 | #include "opt_inet.h" | 83 | #include "opt_inet.h" | |
84 | 84 | |||
85 | #include <sys/param.h> | 85 | #include <sys/param.h> | |
86 | #include <sys/systm.h> | 86 | #include <sys/systm.h> | |
87 | #include <sys/kernel.h> | 87 | #include <sys/kernel.h> | |
88 | #include <sys/mbuf.h> | 88 | #include <sys/mbuf.h> | |
89 | #include <sys/malloc.h> | 89 | #include <sys/malloc.h> | |
90 | #include <sys/proc.h> | 90 | #include <sys/proc.h> | |
91 | #include <sys/socket.h> | 91 | #include <sys/socket.h> | |
92 | #include <sys/sockio.h> | 92 | #include <sys/sockio.h> | |
93 | #include <sys/errno.h> | 93 | #include <sys/errno.h> | |
94 | #include <sys/endian.h> | 94 | #include <sys/endian.h> | |
@@ -696,74 +696,74 @@ awi_start(struct ifnet *ifp) | @@ -696,74 +696,74 @@ awi_start(struct ifnet *ifp) | |||
696 | if (!(ifp->if_flags & IFF_LINK0) && !sc->sc_adhoc_ap) | 696 | if (!(ifp->if_flags & IFF_LINK0) && !sc->sc_adhoc_ap) | |
697 | len += sizeof(struct llc) - | 697 | len += sizeof(struct llc) - | |
698 | sizeof(struct ether_header); | 698 | sizeof(struct ether_header); | |
699 | if (ic->ic_flags & IEEE80211_F_PRIVACY) { | 699 | if (ic->ic_flags & IEEE80211_F_PRIVACY) { | |
700 | dowep = 1; | 700 | dowep = 1; | |
701 | len += IEEE80211_WEP_IVLEN + | 701 | len += IEEE80211_WEP_IVLEN + | |
702 | IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN; | 702 | IEEE80211_WEP_KIDLEN + IEEE80211_WEP_CRCLEN; | |
703 | } | 703 | } | |
704 | if (awi_next_txd(sc, len, &frame, &ntxd)) { | 704 | if (awi_next_txd(sc, len, &frame, &ntxd)) { | |
705 | ifp->if_flags |= IFF_OACTIVE; | 705 | ifp->if_flags |= IFF_OACTIVE; | |
706 | break; | 706 | break; | |
707 | } | 707 | } | |
708 | IFQ_DEQUEUE(&ifp->if_snd, m0); | 708 | IFQ_DEQUEUE(&ifp->if_snd, m0); | |
709 | ifp->if_opackets++; | 709 | if_statinc(ifp, if_opackets); | |
710 | bpf_mtap(ifp, m0, BPF_D_OUT); | 710 | bpf_mtap(ifp, m0, BPF_D_OUT); | |
711 | eh = mtod(m0, struct ether_header *); | 711 | eh = mtod(m0, struct ether_header *); | |
712 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | 712 | ni = ieee80211_find_txnode(ic, eh->ether_dhost); | |
713 | if (ni == NULL) { | 713 | if (ni == NULL) { | |
714 | ifp->if_oerrors++; | 714 | if_statinc(ifp, if_oerrors); | |
715 | continue; | 715 | continue; | |
716 | } | 716 | } | |
717 | if ((ifp->if_flags & IFF_LINK0) || sc->sc_adhoc_ap) | 717 | if ((ifp->if_flags & IFF_LINK0) || sc->sc_adhoc_ap) | |
718 | m0 = awi_ether_encap(sc, m0); | 718 | m0 = awi_ether_encap(sc, m0); | |
719 | else { | 719 | else { | |
720 | m0 = ieee80211_encap(ic, m0, ni); | 720 | m0 = ieee80211_encap(ic, m0, ni); | |
721 | } | 721 | } | |
722 | if (m0 == NULL) { | 722 | if (m0 == NULL) { | |
723 | ieee80211_free_node(ni); | 723 | ieee80211_free_node(ni); | |
724 | ifp->if_oerrors++; | 724 | if_statinc(ifp, if_oerrors); | |
725 | continue; | 725 | continue; | |
726 | } | 726 | } | |
727 | wh = mtod(m0, struct ieee80211_frame *); | 727 | wh = mtod(m0, struct ieee80211_frame *); | |
728 | if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && | 728 | if (!IEEE80211_IS_MULTICAST(wh->i_addr1) && | |
729 | (ic->ic_opmode == IEEE80211_M_HOSTAP || | 729 | (ic->ic_opmode == IEEE80211_M_HOSTAP || | |
730 | ic->ic_opmode == IEEE80211_M_IBSS) && | 730 | ic->ic_opmode == IEEE80211_M_IBSS) && | |
731 | sc->sc_adhoc_ap == 0 && | 731 | sc->sc_adhoc_ap == 0 && | |
732 | (ifp->if_flags & IFF_LINK0) == 0 && | 732 | (ifp->if_flags & IFF_LINK0) == 0 && | |
733 | (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == | 733 | (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == | |
734 | IEEE80211_FC0_TYPE_DATA) { | 734 | IEEE80211_FC0_TYPE_DATA) { | |
735 | m_freem(m0); | 735 | m_freem(m0); | |
736 | ieee80211_free_node(ni); | 736 | ieee80211_free_node(ni); | |
737 | ifp->if_oerrors++; | 737 | if_statinc(ifp, if_oerrors); | |
738 | continue; | 738 | continue; | |
739 | } | 739 | } | |
740 | } | 740 | } | |
741 | bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); | 741 | bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); | |
742 | if (dowep) { | 742 | if (dowep) { | |
743 | if ((ieee80211_crypto_encap(ic, ni, m0)) == NULL) { | 743 | if ((ieee80211_crypto_encap(ic, ni, m0)) == NULL) { | |
744 | m_freem(m0); | 744 | m_freem(m0); | |
745 | ieee80211_free_node(ni); | 745 | ieee80211_free_node(ni); | |
746 | ifp->if_oerrors++; | 746 | if_statinc(ifp, if_oerrors); | |
747 | continue; | 747 | continue; | |
748 | } | 748 | } | |
749 | } | 749 | } | |
750 | ieee80211_free_node(ni); | 750 | ieee80211_free_node(ni); | |
751 | #ifdef DIAGNOSTIC | 751 | #ifdef DIAGNOSTIC | |
752 | if (m0->m_pkthdr.len != len) { | 752 | if (m0->m_pkthdr.len != len) { | |
753 | printf("%s: length %d should be %d\n", | 753 | printf("%s: length %d should be %d\n", | |
754 | sc->sc_if.if_xname, m0->m_pkthdr.len, len); | 754 | sc->sc_if.if_xname, m0->m_pkthdr.len, len); | |
755 | m_freem(m0); | 755 | m_freem(m0); | |
756 | ifp->if_oerrors++; | 756 | if_statinc(ifp, if_oerrors); | |
757 | continue; | 757 | continue; | |
758 | } | 758 | } | |
759 | #endif | 759 | #endif | |
760 | 760 | |||
761 | if ((ifp->if_flags & IFF_DEBUG) && (ifp->if_flags & IFF_LINK2)) | 761 | if ((ifp->if_flags & IFF_DEBUG) && (ifp->if_flags & IFF_LINK2)) | |
762 | ieee80211_dump_pkt(m0->m_data, m0->m_len, | 762 | ieee80211_dump_pkt(m0->m_data, m0->m_len, | |
763 | ic->ic_bss->ni_rates. | 763 | ic->ic_bss->ni_rates. | |
764 | rs_rates[ic->ic_bss->ni_txrate] & | 764 | rs_rates[ic->ic_bss->ni_txrate] & | |
765 | IEEE80211_RATE_VAL, -1); | 765 | IEEE80211_RATE_VAL, -1); | |
766 | 766 | |||
767 | for (m = m0, len = 0; m != NULL; m = m->m_next) { | 767 | for (m = m0, len = 0; m != NULL; m = m->m_next) { | |
768 | awi_write_bytes(sc, frame + len, mtod(m, uint8_t *), | 768 | awi_write_bytes(sc, frame + len, mtod(m, uint8_t *), | |
769 | m->m_len); | 769 | m->m_len); | |
@@ -796,27 +796,27 @@ awi_watchdog(struct ifnet *ifp) | @@ -796,27 +796,27 @@ awi_watchdog(struct ifnet *ifp) | |||
796 | 796 | |||
797 | ifp->if_timer = 0; | 797 | ifp->if_timer = 0; | |
798 | if (!sc->sc_enabled || !device_is_active(sc->sc_dev)) | 798 | if (!sc->sc_enabled || !device_is_active(sc->sc_dev)) | |
799 | return; | 799 | return; | |
800 | 800 | |||
801 | ocansleep = sc->sc_cansleep; | 801 | ocansleep = sc->sc_cansleep; | |
802 | sc->sc_cansleep = 0; | 802 | sc->sc_cansleep = 0; | |
803 | if (sc->sc_tx_timer) { | 803 | if (sc->sc_tx_timer) { | |
804 | if (--sc->sc_tx_timer == 0) { | 804 | if (--sc->sc_tx_timer == 0) { | |
805 | printf("%s: device timeout\n", ifp->if_xname); | 805 | printf("%s: device timeout\n", ifp->if_xname); | |
806 | prevdone = sc->sc_txdone; | 806 | prevdone = sc->sc_txdone; | |
807 | awi_tx_int(sc); | 807 | awi_tx_int(sc); | |
808 | if (sc->sc_txdone == prevdone) { | 808 | if (sc->sc_txdone == prevdone) { | |
809 | ifp->if_oerrors++; | 809 | if_statinc(ifp, if_oerrors); | |
810 | awi_init(ifp); | 810 | awi_init(ifp); | |
811 | goto out; | 811 | goto out; | |
812 | } | 812 | } | |
813 | } | 813 | } | |
814 | ifp->if_timer = 1; | 814 | ifp->if_timer = 1; | |
815 | } | 815 | } | |
816 | if (sc->sc_rx_timer) { | 816 | if (sc->sc_rx_timer) { | |
817 | if (--sc->sc_rx_timer == 0) { | 817 | if (--sc->sc_rx_timer == 0) { | |
818 | if (sc->sc_ic.ic_state == IEEE80211_S_RUN) { | 818 | if (sc->sc_ic.ic_state == IEEE80211_S_RUN) { | |
819 | ieee80211_new_state(&sc->sc_ic, | 819 | ieee80211_new_state(&sc->sc_ic, | |
820 | IEEE80211_S_SCAN, -1); | 820 | IEEE80211_S_SCAN, -1); | |
821 | goto out; | 821 | goto out; | |
822 | } | 822 | } | |
@@ -1074,58 +1074,58 @@ awi_rx_int(struct awi_softc *sc) | @@ -1074,58 +1074,58 @@ awi_rx_int(struct awi_softc *sc) | |||
1074 | uint16_t len; | 1074 | uint16_t len; | |
1075 | uint32_t frame, next, rstamp, rxoff; | 1075 | uint32_t frame, next, rstamp, rxoff; | |
1076 | struct mbuf *m; | 1076 | struct mbuf *m; | |
1077 | 1077 | |||
1078 | rxoff = sc->sc_rxdoff; | 1078 | rxoff = sc->sc_rxdoff; | |
1079 | for (;;) { | 1079 | for (;;) { | |
1080 | state = awi_read_1(sc, rxoff + AWI_RXD_HOST_DESC_STATE); | 1080 | state = awi_read_1(sc, rxoff + AWI_RXD_HOST_DESC_STATE); | |
1081 | if (state & AWI_RXD_ST_OWN) | 1081 | if (state & AWI_RXD_ST_OWN) | |
1082 | break; | 1082 | break; | |
1083 | if (!(state & AWI_RXD_ST_CONSUMED)) { | 1083 | if (!(state & AWI_RXD_ST_CONSUMED)) { | |
1084 | if (sc->sc_substate != AWI_ST_NONE) | 1084 | if (sc->sc_substate != AWI_ST_NONE) | |
1085 | goto rx_next; | 1085 | goto rx_next; | |
1086 | if (state & AWI_RXD_ST_RXERROR) { | 1086 | if (state & AWI_RXD_ST_RXERROR) { | |
1087 | ifp->if_ierrors++; | 1087 | if_statinc(ifp, if_ierrors); | |
1088 | goto rx_next; | 1088 | goto rx_next; | |
1089 | } | 1089 | } | |
1090 | len = awi_read_2(sc, rxoff + AWI_RXD_LEN); | 1090 | len = awi_read_2(sc, rxoff + AWI_RXD_LEN); | |
1091 | rate = awi_read_1(sc, rxoff + AWI_RXD_RATE); | 1091 | rate = awi_read_1(sc, rxoff + AWI_RXD_RATE); | |
1092 | rssi = awi_read_1(sc, rxoff + AWI_RXD_RSSI); | 1092 | rssi = awi_read_1(sc, rxoff + AWI_RXD_RSSI); | |
1093 | frame = awi_read_4(sc, rxoff + AWI_RXD_START_FRAME) & | 1093 | frame = awi_read_4(sc, rxoff + AWI_RXD_START_FRAME) & | |
1094 | 0x7fff; | 1094 | 0x7fff; | |
1095 | rstamp = awi_read_4(sc, rxoff + AWI_RXD_LOCALTIME); | 1095 | rstamp = awi_read_4(sc, rxoff + AWI_RXD_LOCALTIME); | |
1096 | m = awi_devget(sc, frame, len); | 1096 | m = awi_devget(sc, frame, len); | |
1097 | if (m == NULL) { | 1097 | if (m == NULL) { | |
1098 | ifp->if_ierrors++; | 1098 | if_statinc(ifp, if_ierrors); | |
1099 | goto rx_next; | 1099 | goto rx_next; | |
1100 | } | 1100 | } | |
1101 | if (state & AWI_RXD_ST_LF) { | 1101 | if (state & AWI_RXD_ST_LF) { | |
1102 | /* TODO check my bss */ | 1102 | /* TODO check my bss */ | |
1103 | if (!(sc->sc_ic.ic_flags & IEEE80211_F_SIBSS) && | 1103 | if (!(sc->sc_ic.ic_flags & IEEE80211_F_SIBSS) && | |
1104 | sc->sc_ic.ic_state == IEEE80211_S_RUN) { | 1104 | sc->sc_ic.ic_state == IEEE80211_S_RUN) { | |
1105 | sc->sc_rx_timer = 10; | 1105 | sc->sc_rx_timer = 10; | |
1106 | ifp->if_timer = 1; | 1106 | ifp->if_timer = 1; | |
1107 | } | 1107 | } | |
1108 | if ((ifp->if_flags & IFF_DEBUG) && | 1108 | if ((ifp->if_flags & IFF_DEBUG) && | |
1109 | (ifp->if_flags & IFF_LINK2)) | 1109 | (ifp->if_flags & IFF_LINK2)) | |
1110 | ieee80211_dump_pkt(m->m_data, m->m_len, | 1110 | ieee80211_dump_pkt(m->m_data, m->m_len, | |
1111 | rate / 5, rssi); | 1111 | rate / 5, rssi); | |
1112 | if ((ifp->if_flags & IFF_LINK0) || | 1112 | if ((ifp->if_flags & IFF_LINK0) || | |
1113 | sc->sc_adhoc_ap) | 1113 | sc->sc_adhoc_ap) | |
1114 | m = awi_ether_modcap(sc, m); | 1114 | m = awi_ether_modcap(sc, m); | |
1115 | else | 1115 | else | |
1116 | m = m_pullup(m, sizeof(*wh)); | 1116 | m = m_pullup(m, sizeof(*wh)); | |
1117 | if (m == NULL) { | 1117 | if (m == NULL) { | |
1118 | ifp->if_ierrors++; | 1118 | if_statinc(ifp, if_ierrors); | |
1119 | goto rx_next; | 1119 | goto rx_next; | |
1120 | } | 1120 | } | |
1121 | wh = mtod(m, struct ieee80211_frame_min *); | 1121 | wh = mtod(m, struct ieee80211_frame_min *); | |
1122 | ni = ieee80211_find_rxnode(ic, wh); | 1122 | ni = ieee80211_find_rxnode(ic, wh); | |
1123 | ieee80211_input(ic, m, ni, rssi, rstamp); | 1123 | ieee80211_input(ic, m, ni, rssi, rstamp); | |
1124 | /* | 1124 | /* | |
1125 | * The frame may have caused the | 1125 | * The frame may have caused the | |
1126 | * node to be marked for reclamation | 1126 | * node to be marked for reclamation | |
1127 | * (e.g. in response to a DEAUTH | 1127 | * (e.g. in response to a DEAUTH | |
1128 | * message) so use release_node here | 1128 | * message) so use release_node here | |
1129 | * instead of unref_node. | 1129 | * instead of unref_node. | |
1130 | */ | 1130 | */ | |
1131 | ieee80211_free_node(ni); | 1131 | ieee80211_free_node(ni); | |
@@ -1149,27 +1149,27 @@ awi_rx_int(struct awi_softc *sc) | @@ -1149,27 +1149,27 @@ awi_rx_int(struct awi_softc *sc) | |||
1149 | } | 1149 | } | |
1150 | 1150 | |||
1151 | static void | 1151 | static void | |
1152 | awi_tx_int(struct awi_softc *sc) | 1152 | awi_tx_int(struct awi_softc *sc) | |
1153 | { | 1153 | { | |
1154 | struct ifnet *ifp = &sc->sc_if; | 1154 | struct ifnet *ifp = &sc->sc_if; | |
1155 | uint8_t flags; | 1155 | uint8_t flags; | |
1156 | 1156 | |||
1157 | while (sc->sc_txdone != sc->sc_txnext) { | 1157 | while (sc->sc_txdone != sc->sc_txnext) { | |
1158 | flags = awi_read_1(sc, sc->sc_txdone + AWI_TXD_STATE); | 1158 | flags = awi_read_1(sc, sc->sc_txdone + AWI_TXD_STATE); | |
1159 | if ((flags & AWI_TXD_ST_OWN) || !(flags & AWI_TXD_ST_DONE)) | 1159 | if ((flags & AWI_TXD_ST_OWN) || !(flags & AWI_TXD_ST_DONE)) | |
1160 | break; | 1160 | break; | |
1161 | if (flags & AWI_TXD_ST_ERROR) | 1161 | if (flags & AWI_TXD_ST_ERROR) | |
1162 | ifp->if_oerrors++; | 1162 | if_statinc(ifp, if_oerrors); | |
1163 | sc->sc_txdone = awi_read_4(sc, sc->sc_txdone + AWI_TXD_NEXT) & | 1163 | sc->sc_txdone = awi_read_4(sc, sc->sc_txdone + AWI_TXD_NEXT) & | |
1164 | 0x7fff; | 1164 | 0x7fff; | |
1165 | } | 1165 | } | |
1166 | DPRINTF2(("awi_txint: txdone %d txnext %d txbase %d txend %d\n", | 1166 | DPRINTF2(("awi_txint: txdone %d txnext %d txbase %d txend %d\n", | |
1167 | sc->sc_txdone, sc->sc_txnext, sc->sc_txbase, sc->sc_txend)); | 1167 | sc->sc_txdone, sc->sc_txnext, sc->sc_txbase, sc->sc_txend)); | |
1168 | sc->sc_tx_timer = 0; | 1168 | sc->sc_tx_timer = 0; | |
1169 | ifp->if_flags &= ~IFF_OACTIVE; | 1169 | ifp->if_flags &= ~IFF_OACTIVE; | |
1170 | awi_start(ifp); /* in softint */ | 1170 | awi_start(ifp); /* in softint */ | |
1171 | } | 1171 | } | |
1172 | 1172 | |||
1173 | static struct mbuf * | 1173 | static struct mbuf * | |
1174 | awi_devget(struct awi_softc *sc, uint32_t off, uint16_t len) | 1174 | awi_devget(struct awi_softc *sc, uint32_t off, uint16_t len) | |
1175 | { | 1175 | { |