Wed Jan 29 06:35:28 2020 UTC ()
Adopt <net/if_stats.h>.


(thorpej)
diff -r1.40 -r1.41 src/sys/dev/usb/if_otus.c
diff -r1.65 -r1.66 src/sys/dev/usb/if_rum.c
diff -r1.35 -r1.36 src/sys/dev/usb/if_run.c
diff -r1.62 -r1.63 src/sys/dev/usb/if_smsc.c
diff -r1.73 -r1.74 src/sys/dev/usb/if_udav.c
diff -r1.10 -r1.11 src/sys/dev/usb/if_umb.c
diff -r1.27 -r1.28 src/sys/dev/usb/if_upgt.c
diff -r1.69 -r1.70 src/sys/dev/usb/if_upl.c
diff -r1.61 -r1.62 src/sys/dev/usb/if_ural.c

cvs diff -r1.40 -r1.41 src/sys/dev/usb/if_otus.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_otus.c 2020/01/15 08:20:13 1.40
+++ src/sys/dev/usb/if_otus.c 2020/01/29 06:35:28 1.41
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: if_otus.c,v 1.40 2020/01/15 08:20:13 skrll Exp $ */ 1/* $NetBSD: if_otus.c,v 1.41 2020/01/29 06:35:28 thorpej Exp $ */
2/* $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $ */ 2/* $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg 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 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above 8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies. 9 * copyright notice and this permission notice appear in all copies.
10 * 10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */ 18 */
19 19
20/*- 20/*-
21 * Driver for Atheros AR9001U chipset. 21 * Driver for Atheros AR9001U chipset.
22 * http://www.atheros.com/pt/bulletins/AR9001USBBulletin.pdf 22 * http://www.atheros.com/pt/bulletins/AR9001USBBulletin.pdf
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.40 2020/01/15 08:20:13 skrll Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.41 2020/01/29 06:35:28 thorpej Exp $");
27 27
28#ifdef _KERNEL_OPT 28#ifdef _KERNEL_OPT
29#include "opt_usb.h" 29#include "opt_usb.h"
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/kmem.h> 36#include <sys/kmem.h>
37#include <sys/kthread.h> 37#include <sys/kthread.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/callout.h> 39#include <sys/callout.h>
@@ -1724,69 +1724,69 @@ otus_sub_rxeof(struct otus_softc *sc, ui @@ -1724,69 +1724,69 @@ otus_sub_rxeof(struct otus_softc *sc, ui
1724 } 1724 }
1725 plcp = buf; 1725 plcp = buf;
1726 1726
1727 /* All bits in the PLCP header are set to 1 for non-MPDU. */ 1727 /* All bits in the PLCP header are set to 1 for non-MPDU. */
1728 if (memcmp(plcp, AR_PLCP_HDR_INTR, AR_PLCP_HDR_LEN) == 0) { 1728 if (memcmp(plcp, AR_PLCP_HDR_INTR, AR_PLCP_HDR_LEN) == 0) {
1729 otus_cmd_rxeof(sc, plcp + AR_PLCP_HDR_LEN, 1729 otus_cmd_rxeof(sc, plcp + AR_PLCP_HDR_LEN,
1730 len - AR_PLCP_HDR_LEN); 1730 len - AR_PLCP_HDR_LEN);
1731 return; 1731 return;
1732 } 1732 }
1733 1733
1734 /* Received MPDU. */ 1734 /* Received MPDU. */
1735 if (__predict_false(len < AR_PLCP_HDR_LEN + sizeof(*tail))) { 1735 if (__predict_false(len < AR_PLCP_HDR_LEN + sizeof(*tail))) {
1736 DPRINTFN(DBG_RX, sc, "MPDU too short %d\n", len); 1736 DPRINTFN(DBG_RX, sc, "MPDU too short %d\n", len);
1737 ifp->if_ierrors++; 1737 if_statinc(ifp, if_ierrors);
1738 return; 1738 return;
1739 } 1739 }
1740 tail = (void *)(plcp + len - sizeof(*tail)); 1740 tail = (void *)(plcp + len - sizeof(*tail));
1741 wh = (void *)(plcp + AR_PLCP_HDR_LEN); 1741 wh = (void *)(plcp + AR_PLCP_HDR_LEN);
1742 1742
1743 /* Discard error frames. */ 1743 /* Discard error frames. */
1744 if (__predict_false((tail->error & sc->sc_rx_error_msk) != 0)) { 1744 if (__predict_false((tail->error & sc->sc_rx_error_msk) != 0)) {
1745 DPRINTFN(DBG_RX, sc, "error frame 0x%02x\n", tail->error); 1745 DPRINTFN(DBG_RX, sc, "error frame 0x%02x\n", tail->error);
1746 if (tail->error & AR_RX_ERROR_FCS) { 1746 if (tail->error & AR_RX_ERROR_FCS) {
1747 DPRINTFN(DBG_RX, sc, "bad FCS\n"); 1747 DPRINTFN(DBG_RX, sc, "bad FCS\n");
1748 } else if (tail->error & AR_RX_ERROR_MMIC) { 1748 } else if (tail->error & AR_RX_ERROR_MMIC) {
1749 /* Report Michael MIC failures to net80211. */ 1749 /* Report Michael MIC failures to net80211. */
1750 ieee80211_notify_michael_failure(ic, wh, 0 /* XXX: keyix */); 1750 ieee80211_notify_michael_failure(ic, wh, 0 /* XXX: keyix */);
1751 } 1751 }
1752 ifp->if_ierrors++; 1752 if_statinc(ifp, if_ierrors);
1753 return; 1753 return;
1754 } 1754 }
1755 /* Compute MPDU's length. */ 1755 /* Compute MPDU's length. */
1756 mlen = len - AR_PLCP_HDR_LEN - sizeof(*tail); 1756 mlen = len - AR_PLCP_HDR_LEN - sizeof(*tail);
1757 mlen -= IEEE80211_CRC_LEN; /* strip 802.11 FCS */ 1757 mlen -= IEEE80211_CRC_LEN; /* strip 802.11 FCS */
1758 /* Make sure there's room for an 802.11 header. */ 1758 /* Make sure there's room for an 802.11 header. */
1759 /* 1759 /*
1760 * XXX: This will drop most control packets. Do we really 1760 * XXX: This will drop most control packets. Do we really
1761 * want this in IEEE80211_M_MONITOR mode? 1761 * want this in IEEE80211_M_MONITOR mode?
1762 */ 1762 */
1763 if (__predict_false(mlen < sizeof(*wh))) { 1763 if (__predict_false(mlen < sizeof(*wh))) {
1764 ifp->if_ierrors++; 1764 if_statinc(ifp, if_ierrors);
1765 return; 1765 return;
1766 } 1766 }
1767 1767
1768 /* Provide a 32-bit aligned protocol header to the stack. */ 1768 /* Provide a 32-bit aligned protocol header to the stack. */
1769 align = (ieee80211_has_qos(wh) ^ ieee80211_has_addr4(wh)) ? 2 : 0; 1769 align = (ieee80211_has_qos(wh) ^ ieee80211_has_addr4(wh)) ? 2 : 0;
1770 1770
1771 MGETHDR(m, M_DONTWAIT, MT_DATA); 1771 MGETHDR(m, M_DONTWAIT, MT_DATA);
1772 if (__predict_false(m == NULL)) { 1772 if (__predict_false(m == NULL)) {
1773 ifp->if_ierrors++; 1773 if_statinc(ifp, if_ierrors);
1774 return; 1774 return;
1775 } 1775 }
1776 if (align + mlen > MHLEN) { 1776 if (align + mlen > MHLEN) {
1777 MCLGET(m, M_DONTWAIT); 1777 MCLGET(m, M_DONTWAIT);
1778 if (__predict_false(!(m->m_flags & M_EXT))) { 1778 if (__predict_false(!(m->m_flags & M_EXT))) {
1779 ifp->if_ierrors++; 1779 if_statinc(ifp, if_ierrors);
1780 m_freem(m); 1780 m_freem(m);
1781 return; 1781 return;
1782 } 1782 }
1783 } 1783 }
1784 /* Finalize mbuf. */ 1784 /* Finalize mbuf. */
1785 m_set_rcvif(m, ifp); 1785 m_set_rcvif(m, ifp);
1786 m->m_data += align; 1786 m->m_data += align;
1787 memcpy(mtod(m, void *), wh, mlen); 1787 memcpy(mtod(m, void *), wh, mlen);
1788 m->m_pkthdr.len = m->m_len = mlen; 1788 m->m_pkthdr.len = m->m_len = mlen;
1789 1789
1790 s = splnet(); 1790 s = splnet();
1791 if (__predict_false(sc->sc_drvbpf != NULL)) { 1791 if (__predict_false(sc->sc_drvbpf != NULL)) {
1792 struct otus_rx_radiotap_header *tap; 1792 struct otus_rx_radiotap_header *tap;
@@ -1907,30 +1907,30 @@ otus_txeof(struct usbd_xfer *xfer, void  @@ -1907,30 +1907,30 @@ otus_txeof(struct usbd_xfer *xfer, void
1907 DPRINTFN(DBG_FN, sc, "\n"); 1907 DPRINTFN(DBG_FN, sc, "\n");
1908 1908
1909 /* Put this Tx buffer back to the free list. */ 1909 /* Put this Tx buffer back to the free list. */
1910 mutex_enter(&sc->sc_tx_mtx); 1910 mutex_enter(&sc->sc_tx_mtx);
1911 TAILQ_INSERT_TAIL(&sc->sc_tx_free_list, data, next); 1911 TAILQ_INSERT_TAIL(&sc->sc_tx_free_list, data, next);
1912 mutex_exit(&sc->sc_tx_mtx); 1912 mutex_exit(&sc->sc_tx_mtx);
1913 1913
1914 ic = &sc->sc_ic; 1914 ic = &sc->sc_ic;
1915 ifp = ic->ic_ifp; 1915 ifp = ic->ic_ifp;
1916 if (__predict_false(status != USBD_NORMAL_COMPLETION)) { 1916 if (__predict_false(status != USBD_NORMAL_COMPLETION)) {
1917 DPRINTFN(DBG_TX, sc, "TX status=%d\n", status); 1917 DPRINTFN(DBG_TX, sc, "TX status=%d\n", status);
1918 if (status == USBD_STALLED) 1918 if (status == USBD_STALLED)
1919 usbd_clear_endpoint_stall_async(sc->sc_data_tx_pipe); 1919 usbd_clear_endpoint_stall_async(sc->sc_data_tx_pipe);
1920 ifp->if_oerrors++; 1920 if_statinc(ifp, if_oerrors);
1921 return; 1921 return;
1922 } 1922 }
1923 ifp->if_opackets++; 1923 if_statinc(ifp, if_opackets);
1924 1924
1925 s = splnet(); 1925 s = splnet();
1926 sc->sc_tx_timer = 0; 1926 sc->sc_tx_timer = 0;
1927 ifp->if_flags &= ~IFF_OACTIVE; /* XXX: do after freeing Tx buffer? */ 1927 ifp->if_flags &= ~IFF_OACTIVE; /* XXX: do after freeing Tx buffer? */
1928 otus_start(ifp); 1928 otus_start(ifp);
1929 splx(s); 1929 splx(s);
1930} 1930}
1931 1931
1932Static int 1932Static int
1933otus_tx(struct otus_softc *sc, struct mbuf *m, struct ieee80211_node *ni, 1933otus_tx(struct otus_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
1934 struct otus_tx_data *data) 1934 struct otus_tx_data *data)
1935{ 1935{
1936 struct ieee80211com *ic; 1936 struct ieee80211com *ic;
@@ -2104,53 +2104,53 @@ otus_start(struct ifnet *ifp) @@ -2104,53 +2104,53 @@ otus_start(struct ifnet *ifp)
2104 goto sendit; 2104 goto sendit;
2105 } 2105 }
2106 2106
2107 if (ic->ic_state != IEEE80211_S_RUN) 2107 if (ic->ic_state != IEEE80211_S_RUN)
2108 break; 2108 break;
2109 2109
2110 /* Encapsulate and send data frames. */ 2110 /* Encapsulate and send data frames. */
2111 IFQ_DEQUEUE(&ifp->if_snd, m); 2111 IFQ_DEQUEUE(&ifp->if_snd, m);
2112 if (m == NULL) 2112 if (m == NULL)
2113 break; 2113 break;
2114 2114
2115 if (m->m_len < (int)sizeof(*eh) && 2115 if (m->m_len < (int)sizeof(*eh) &&
2116 (m = m_pullup(m, sizeof(*eh))) == NULL) { 2116 (m = m_pullup(m, sizeof(*eh))) == NULL) {
2117 ifp->if_oerrors++; 2117 if_statinc(ifp, if_oerrors);
2118 continue; 2118 continue;
2119 } 2119 }
2120 2120
2121 eh = mtod(m, struct ether_header *); 2121 eh = mtod(m, struct ether_header *);
2122 ni = ieee80211_find_txnode(ic, eh->ether_dhost); 2122 ni = ieee80211_find_txnode(ic, eh->ether_dhost);
2123 if (ni == NULL) { 2123 if (ni == NULL) {
2124 m_freem(m); 2124 m_freem(m);
2125 ifp->if_oerrors++; 2125 if_statinc(ifp, if_oerrors);
2126 continue; 2126 continue;
2127 } 2127 }
2128 2128
2129 bpf_mtap(ifp, m, BPF_D_OUT); 2129 bpf_mtap(ifp, m, BPF_D_OUT);
2130 2130
2131 if ((m = ieee80211_encap(ic, m, ni)) == NULL) { 2131 if ((m = ieee80211_encap(ic, m, ni)) == NULL) {
2132 /* original m was freed by ieee80211_encap() */ 2132 /* original m was freed by ieee80211_encap() */
2133 ieee80211_free_node(ni); 2133 ieee80211_free_node(ni);
2134 ifp->if_oerrors++; 2134 if_statinc(ifp, if_oerrors);
2135 continue; 2135 continue;
2136 } 2136 }
2137 sendit: 2137 sendit:
2138 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); 2138 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
2139 2139
2140 if (otus_tx(sc, m, ni, data) != 0) { 2140 if (otus_tx(sc, m, ni, data) != 0) {
2141 m_freem(m); 2141 m_freem(m);
2142 ieee80211_free_node(ni); 2142 ieee80211_free_node(ni);
2143 ifp->if_oerrors++; 2143 if_statinc(ifp, if_oerrors);
2144 continue; 2144 continue;
2145 } 2145 }
2146 2146
2147 data = NULL; /* we're finished with this data buffer */ 2147 data = NULL; /* we're finished with this data buffer */
2148 m_freem(m); 2148 m_freem(m);
2149 ieee80211_free_node(ni); 2149 ieee80211_free_node(ni);
2150 sc->sc_tx_timer = 5; 2150 sc->sc_tx_timer = 5;
2151 ifp->if_timer = 1; 2151 ifp->if_timer = 1;
2152 } 2152 }
2153 2153
2154 /* 2154 /*
2155 * If here, we have a Tx buffer, but ran out of mbufs to 2155 * If here, we have a Tx buffer, but ran out of mbufs to
2156 * transmit. Put the Tx buffer back to the free list. 2156 * transmit. Put the Tx buffer back to the free list.
@@ -2165,27 +2165,27 @@ otus_watchdog(struct ifnet *ifp) @@ -2165,27 +2165,27 @@ otus_watchdog(struct ifnet *ifp)
2165{ 2165{
2166 struct otus_softc *sc; 2166 struct otus_softc *sc;
2167 2167
2168 sc = ifp->if_softc; 2168 sc = ifp->if_softc;
2169 2169
2170 DPRINTFN(DBG_FN, sc, "\n"); 2170 DPRINTFN(DBG_FN, sc, "\n");
2171 2171
2172 ifp->if_timer = 0; 2172 ifp->if_timer = 0;
2173 2173
2174 if (sc->sc_tx_timer > 0) { 2174 if (sc->sc_tx_timer > 0) {
2175 if (--sc->sc_tx_timer == 0) { 2175 if (--sc->sc_tx_timer == 0) {
2176 aprint_error_dev(sc->sc_dev, "device timeout\n"); 2176 aprint_error_dev(sc->sc_dev, "device timeout\n");
2177 /* otus_init(ifp); XXX needs a process context! */ 2177 /* otus_init(ifp); XXX needs a process context! */
2178 ifp->if_oerrors++; 2178 if_statinc(ifp, if_oerrors);
2179 return; 2179 return;
2180 } 2180 }
2181 ifp->if_timer = 1; 2181 ifp->if_timer = 1;
2182 } 2182 }
2183 ieee80211_watchdog(&sc->sc_ic); 2183 ieee80211_watchdog(&sc->sc_ic);
2184} 2184}
2185 2185
2186Static int 2186Static int
2187otus_ioctl(struct ifnet *ifp, u_long cmd, void *data) 2187otus_ioctl(struct ifnet *ifp, u_long cmd, void *data)
2188{ 2188{
2189 struct otus_softc *sc; 2189 struct otus_softc *sc;
2190 struct ieee80211com *ic; 2190 struct ieee80211com *ic;
2191 int s, error = 0; 2191 int s, error = 0;

cvs diff -r1.65 -r1.66 src/sys/dev/usb/if_rum.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_rum.c 2019/05/05 03:17:54 1.65
+++ src/sys/dev/usb/if_rum.c 2020/01/29 06:35:28 1.66
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $ */ 1/* $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $ */
2/* $NetBSD: if_rum.c,v 1.65 2019/05/05 03:17:54 mrg Exp $ */ 2/* $NetBSD: if_rum.c,v 1.66 2020/01/29 06:35:28 thorpej Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini@free.fr>
6 * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org> 6 * Copyright (c) 2006 Niall O'Higgins <niallo@openbsd.org>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20 20
21/*- 21/*-
22 * Ralink Technology RT2501USB/RT2601USB chipset driver 22 * Ralink Technology RT2501USB/RT2601USB chipset driver
23 * http://www.ralinktech.com.tw/ 23 * http://www.ralinktech.com.tw/
24 */ 24 */
25 25
26#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.65 2019/05/05 03:17:54 mrg Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.66 2020/01/29 06:35:28 thorpej Exp $");
28 28
29#ifdef _KERNEL_OPT 29#ifdef _KERNEL_OPT
30#include "opt_usb.h" 30#include "opt_usb.h"
31#endif 31#endif
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/sockio.h> 34#include <sys/sockio.h>
35#include <sys/sysctl.h> 35#include <sys/sysctl.h>
36#include <sys/mbuf.h> 36#include <sys/mbuf.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <sys/socket.h> 38#include <sys/socket.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/module.h> 40#include <sys/module.h>
@@ -766,37 +766,37 @@ rum_txeof(struct usbd_xfer *xfer, void * @@ -766,37 +766,37 @@ rum_txeof(struct usbd_xfer *xfer, void *
766 struct ifnet *ifp = &sc->sc_if; 766 struct ifnet *ifp = &sc->sc_if;
767 int s; 767 int s;
768 768
769 if (status != USBD_NORMAL_COMPLETION) { 769 if (status != USBD_NORMAL_COMPLETION) {
770 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 770 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
771 return; 771 return;
772 772
773 printf("%s: could not transmit buffer: %s\n", 773 printf("%s: could not transmit buffer: %s\n",
774 device_xname(sc->sc_dev), usbd_errstr(status)); 774 device_xname(sc->sc_dev), usbd_errstr(status));
775 775
776 if (status == USBD_STALLED) 776 if (status == USBD_STALLED)
777 usbd_clear_endpoint_stall_async(sc->sc_tx_pipeh); 777 usbd_clear_endpoint_stall_async(sc->sc_tx_pipeh);
778 778
779 ifp->if_oerrors++; 779 if_statinc(ifp, if_oerrors);
780 return; 780 return;
781 } 781 }
782 782
783 s = splnet(); 783 s = splnet();
784 784
785 ieee80211_free_node(data->ni); 785 ieee80211_free_node(data->ni);
786 data->ni = NULL; 786 data->ni = NULL;
787 787
788 sc->tx_queued--; 788 sc->tx_queued--;
789 ifp->if_opackets++; 789 if_statinc(ifp, if_opackets);
790 790
791 DPRINTFN(10, ("tx done\n")); 791 DPRINTFN(10, ("tx done\n"));
792 792
793 sc->sc_tx_timer = 0; 793 sc->sc_tx_timer = 0;
794 ifp->if_flags &= ~IFF_OACTIVE; 794 ifp->if_flags &= ~IFF_OACTIVE;
795 rum_start(ifp); 795 rum_start(ifp);
796 796
797 splx(s); 797 splx(s);
798} 798}
799 799
800static void 800static void
801rum_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status) 801rum_rxeof(struct usbd_xfer *xfer, void *priv, usbd_status status)
802{ 802{
@@ -815,56 +815,56 @@ rum_rxeof(struct usbd_xfer *xfer, void * @@ -815,56 +815,56 @@ rum_rxeof(struct usbd_xfer *xfer, void *
815 return; 815 return;
816 816
817 if (status == USBD_STALLED) 817 if (status == USBD_STALLED)
818 usbd_clear_endpoint_stall_async(sc->sc_rx_pipeh); 818 usbd_clear_endpoint_stall_async(sc->sc_rx_pipeh);
819 goto skip; 819 goto skip;
820 } 820 }
821 821
822 usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL); 822 usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
823 823
824 if (len < (int)(RT2573_RX_DESC_SIZE + 824 if (len < (int)(RT2573_RX_DESC_SIZE +
825 sizeof(struct ieee80211_frame_min))) { 825 sizeof(struct ieee80211_frame_min))) {
826 DPRINTF(("%s: xfer too short %d\n", device_xname(sc->sc_dev), 826 DPRINTF(("%s: xfer too short %d\n", device_xname(sc->sc_dev),
827 len)); 827 len));
828 ifp->if_ierrors++; 828 if_statinc(ifp, if_ierrors);
829 goto skip; 829 goto skip;
830 } 830 }
831 831
832 desc = (struct rum_rx_desc *)data->buf; 832 desc = (struct rum_rx_desc *)data->buf;
833 833
834 if (le32toh(desc->flags) & RT2573_RX_CRC_ERROR) { 834 if (le32toh(desc->flags) & RT2573_RX_CRC_ERROR) {
835 /* 835 /*
836 * This should not happen since we did not request to receive 836 * This should not happen since we did not request to receive
837 * those frames when we filled RT2573_TXRX_CSR0. 837 * those frames when we filled RT2573_TXRX_CSR0.
838 */ 838 */
839 DPRINTFN(5, ("CRC error\n")); 839 DPRINTFN(5, ("CRC error\n"));
840 ifp->if_ierrors++; 840 if_statinc(ifp, if_ierrors);
841 goto skip; 841 goto skip;
842 } 842 }
843 843
844 MGETHDR(mnew, M_DONTWAIT, MT_DATA); 844 MGETHDR(mnew, M_DONTWAIT, MT_DATA);
845 if (mnew == NULL) { 845 if (mnew == NULL) {
846 printf("%s: could not allocate rx mbuf\n", 846 printf("%s: could not allocate rx mbuf\n",
847 device_xname(sc->sc_dev)); 847 device_xname(sc->sc_dev));
848 ifp->if_ierrors++; 848 if_statinc(ifp, if_ierrors);
849 goto skip; 849 goto skip;
850 } 850 }
851 851
852 MCLGET(mnew, M_DONTWAIT); 852 MCLGET(mnew, M_DONTWAIT);
853 if (!(mnew->m_flags & M_EXT)) { 853 if (!(mnew->m_flags & M_EXT)) {
854 printf("%s: could not allocate rx mbuf cluster\n", 854 printf("%s: could not allocate rx mbuf cluster\n",
855 device_xname(sc->sc_dev)); 855 device_xname(sc->sc_dev));
856 m_freem(mnew); 856 m_freem(mnew);
857 ifp->if_ierrors++; 857 if_statinc(ifp, if_ierrors);
858 goto skip; 858 goto skip;
859 } 859 }
860 860
861 m = data->m; 861 m = data->m;
862 data->m = mnew; 862 data->m = mnew;
863 data->buf = mtod(data->m, uint8_t *); 863 data->buf = mtod(data->m, uint8_t *);
864 864
865 /* finalize mbuf */ 865 /* finalize mbuf */
866 m_set_rcvif(m, ifp); 866 m_set_rcvif(m, ifp);
867 m->m_data = (void *)(desc + 1); 867 m->m_data = (void *)(desc + 1);
868 m->m_pkthdr.len = m->m_len = (le32toh(desc->flags) >> 16) & 0xfff; 868 m->m_pkthdr.len = m->m_len = (le32toh(desc->flags) >> 16) & 0xfff;
869 869
870 s = splnet(); 870 s = splnet();
@@ -1291,49 +1291,49 @@ rum_start(struct ifnet *ifp) @@ -1291,49 +1291,49 @@ rum_start(struct ifnet *ifp)
1291 if (ni == NULL) { 1291 if (ni == NULL) {
1292 m_freem(m0); 1292 m_freem(m0);
1293 continue; 1293 continue;
1294 } 1294 }
1295 bpf_mtap(ifp, m0, BPF_D_OUT); 1295 bpf_mtap(ifp, m0, BPF_D_OUT);
1296 m0 = ieee80211_encap(ic, m0, ni); 1296 m0 = ieee80211_encap(ic, m0, ni);
1297 if (m0 == NULL) { 1297 if (m0 == NULL) {
1298 ieee80211_free_node(ni); 1298 ieee80211_free_node(ni);
1299 continue; 1299 continue;
1300 } 1300 }
1301 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); 1301 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
1302 if (rum_tx_data(sc, m0, ni) != 0) { 1302 if (rum_tx_data(sc, m0, ni) != 0) {
1303 ieee80211_free_node(ni); 1303 ieee80211_free_node(ni);
1304 ifp->if_oerrors++; 1304 if_statinc(ifp, if_oerrors);
1305 break; 1305 break;
1306 } 1306 }
1307 } 1307 }
1308 1308
1309 sc->sc_tx_timer = 5; 1309 sc->sc_tx_timer = 5;
1310 ifp->if_timer = 1; 1310 ifp->if_timer = 1;
1311 } 1311 }
1312} 1312}
1313 1313
1314static void 1314static void
1315rum_watchdog(struct ifnet *ifp) 1315rum_watchdog(struct ifnet *ifp)
1316{ 1316{
1317 struct rum_softc *sc = ifp->if_softc; 1317 struct rum_softc *sc = ifp->if_softc;
1318 struct ieee80211com *ic = &sc->sc_ic; 1318 struct ieee80211com *ic = &sc->sc_ic;
1319 1319
1320 ifp->if_timer = 0; 1320 ifp->if_timer = 0;
1321 1321
1322 if (sc->sc_tx_timer > 0) { 1322 if (sc->sc_tx_timer > 0) {
1323 if (--sc->sc_tx_timer == 0) { 1323 if (--sc->sc_tx_timer == 0) {
1324 printf("%s: device timeout\n", device_xname(sc->sc_dev)); 1324 printf("%s: device timeout\n", device_xname(sc->sc_dev));
1325 /*rum_init(ifp); XXX needs a process context! */ 1325 /*rum_init(ifp); XXX needs a process context! */
1326 ifp->if_oerrors++; 1326 if_statinc(ifp, if_oerrors);
1327 return; 1327 return;
1328 } 1328 }
1329 ifp->if_timer = 1; 1329 ifp->if_timer = 1;
1330 } 1330 }
1331 1331
1332 ieee80211_watchdog(ic); 1332 ieee80211_watchdog(ic);
1333} 1333}
1334 1334
1335static int 1335static int
1336rum_ioctl(struct ifnet *ifp, u_long cmd, void *data) 1336rum_ioctl(struct ifnet *ifp, u_long cmd, void *data)
1337{ 1337{
1338#define IS_RUNNING(ifp) \ 1338#define IS_RUNNING(ifp) \
1339 (((ifp)->if_flags & IFF_UP) && ((ifp)->if_flags & IFF_RUNNING)) 1339 (((ifp)->if_flags & IFF_UP) && ((ifp)->if_flags & IFF_RUNNING))
@@ -2248,27 +2248,27 @@ static void @@ -2248,27 +2248,27 @@ static void
2248rum_amrr_update(struct usbd_xfer *xfer, void *priv, 2248rum_amrr_update(struct usbd_xfer *xfer, void *priv,
2249 usbd_status status) 2249 usbd_status status)
2250{ 2250{
2251 struct rum_softc *sc = (struct rum_softc *)priv; 2251 struct rum_softc *sc = (struct rum_softc *)priv;
2252 struct ifnet *ifp = sc->sc_ic.ic_ifp; 2252 struct ifnet *ifp = sc->sc_ic.ic_ifp;
2253 2253
2254 if (status != USBD_NORMAL_COMPLETION) { 2254 if (status != USBD_NORMAL_COMPLETION) {
2255 printf("%s: could not retrieve Tx statistics - cancelling " 2255 printf("%s: could not retrieve Tx statistics - cancelling "
2256 "automatic rate control\n", device_xname(sc->sc_dev)); 2256 "automatic rate control\n", device_xname(sc->sc_dev));
2257 return; 2257 return;
2258 } 2258 }
2259 2259
2260 /* count TX retry-fail as Tx errors */ 2260 /* count TX retry-fail as Tx errors */
2261 ifp->if_oerrors += le32toh(sc->sta[5]) >> 16; 2261 if_statadd(ifp, if_oerrors, le32toh(sc->sta[5]) >> 16);
2262 2262
2263 sc->amn.amn_retrycnt = 2263 sc->amn.amn_retrycnt =
2264 (le32toh(sc->sta[4]) >> 16) + /* TX one-retry ok count */ 2264 (le32toh(sc->sta[4]) >> 16) + /* TX one-retry ok count */
2265 (le32toh(sc->sta[5]) & 0xffff) + /* TX more-retry ok count */ 2265 (le32toh(sc->sta[5]) & 0xffff) + /* TX more-retry ok count */
2266 (le32toh(sc->sta[5]) >> 16); /* TX retry-fail count */ 2266 (le32toh(sc->sta[5]) >> 16); /* TX retry-fail count */
2267 2267
2268 sc->amn.amn_txcnt = 2268 sc->amn.amn_txcnt =
2269 sc->amn.amn_retrycnt + 2269 sc->amn.amn_retrycnt +
2270 (le32toh(sc->sta[4]) & 0xffff); /* TX no-retry ok count */ 2270 (le32toh(sc->sta[4]) & 0xffff); /* TX no-retry ok count */
2271 2271
2272 ieee80211_amrr_choose(&sc->amrr, sc->sc_ic.ic_bss, &sc->amn); 2272 ieee80211_amrr_choose(&sc->amrr, sc->sc_ic.ic_bss, &sc->amn);
2273 2273
2274 callout_reset(&sc->sc_amrr_ch, hz, rum_amrr_timeout, sc); 2274 callout_reset(&sc->sc_amrr_ch, hz, rum_amrr_timeout, sc);

cvs diff -r1.35 -r1.36 src/sys/dev/usb/if_run.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_run.c 2020/01/04 22:30:06 1.35
+++ src/sys/dev/usb/if_run.c 2020/01/29 06:35:28 1.36
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: if_run.c,v 1.35 2020/01/04 22:30:06 mlelstv Exp $ */ 1/* $NetBSD: if_run.c,v 1.36 2020/01/29 06:35:28 thorpej Exp $ */
2/* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */ 2/* $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2008-2010 Damien Bergamini <damien.bergamini@free.fr>
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above 8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies. 9 * copyright notice and this permission notice appear in all copies.
10 * 10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */ 18 */
19 19
20/*- 20/*-
21 * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver. 21 * Ralink Technology RT2700U/RT2800U/RT3000U/RT3900E chipset driver.
22 * http://www.ralinktech.com/ 22 * http://www.ralinktech.com/
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.35 2020/01/04 22:30:06 mlelstv Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.36 2020/01/29 06:35:28 thorpej Exp $");
27 27
28#ifdef _KERNEL_OPT 28#ifdef _KERNEL_OPT
29#include "opt_usb.h" 29#include "opt_usb.h"
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/sysctl.h> 34#include <sys/sysctl.h>
35#include <sys/mbuf.h> 35#include <sys/mbuf.h>
36#include <sys/kernel.h> 36#include <sys/kernel.h>
37#include <sys/socket.h> 37#include <sys/socket.h>
38#include <sys/systm.h> 38#include <sys/systm.h>
39#include <sys/malloc.h> 39#include <sys/malloc.h>
@@ -2147,27 +2147,27 @@ run_calibrate_cb(struct run_softc *sc, v @@ -2147,27 +2147,27 @@ run_calibrate_cb(struct run_softc *sc, v
2147 2147
2148 /* read statistic counters (clear on read) and update AMRR state */ 2148 /* read statistic counters (clear on read) and update AMRR state */
2149 error = run_read_region_1(sc, RT2860_TX_STA_CNT0, (uint8_t *)sta, 2149 error = run_read_region_1(sc, RT2860_TX_STA_CNT0, (uint8_t *)sta,
2150 sizeof(sta)); 2150 sizeof(sta));
2151 if (error != 0) 2151 if (error != 0)
2152 goto skip; 2152 goto skip;
2153 2153
2154 DPRINTF(("retrycnt=%d txcnt=%d failcnt=%d\n", 2154 DPRINTF(("retrycnt=%d txcnt=%d failcnt=%d\n",
2155 le32toh(sta[1]) >> 16, le32toh(sta[1]) & 0xffff, 2155 le32toh(sta[1]) >> 16, le32toh(sta[1]) & 0xffff,
2156 le32toh(sta[0]) & 0xffff)); 2156 le32toh(sta[0]) & 0xffff));
2157 2157
2158 s = splnet(); 2158 s = splnet();
2159 /* count failed TX as errors */ 2159 /* count failed TX as errors */
2160 ifp->if_oerrors += le32toh(sta[0]) & 0xffff; 2160 if_statadd(ifp, if_oerrors, le32toh(sta[0]) & 0xffff);
2161 2161
2162 sc->amn.amn_retrycnt = 2162 sc->amn.amn_retrycnt =
2163 (le32toh(sta[0]) & 0xffff) + /* failed TX count */ 2163 (le32toh(sta[0]) & 0xffff) + /* failed TX count */
2164 (le32toh(sta[1]) >> 16); /* TX retransmission count */ 2164 (le32toh(sta[1]) >> 16); /* TX retransmission count */
2165 2165
2166 sc->amn.amn_txcnt = 2166 sc->amn.amn_txcnt =
2167 sc->amn.amn_retrycnt + 2167 sc->amn.amn_retrycnt +
2168 (le32toh(sta[1]) & 0xffff); /* successful TX count */ 2168 (le32toh(sta[1]) & 0xffff); /* successful TX count */
2169 2169
2170 ieee80211_amrr_choose(&sc->amrr, sc->sc_ic.ic_bss, &sc->amn); 2170 ieee80211_amrr_choose(&sc->amrr, sc->sc_ic.ic_bss, &sc->amn);
2171 splx(s); 2171 splx(s);
2172 2172
2173skip: callout_schedule(&sc->calib_to, hz); 2173skip: callout_schedule(&sc->calib_to, hz);
@@ -2256,62 +2256,62 @@ run_rx_frame(struct run_softc *sc, uint8 @@ -2256,62 +2256,62 @@ run_rx_frame(struct run_softc *sc, uint8
2256 rxwisize += sizeof(uint64_t); 2256 rxwisize += sizeof(uint64_t);
2257 else if (sc->mac_ver == 0x3593) 2257 else if (sc->mac_ver == 0x3593)
2258 rxwisize += sizeof(uint32_t); 2258 rxwisize += sizeof(uint32_t);
2259 len = le16toh(rxwi->len) & 0xfff; 2259 len = le16toh(rxwi->len) & 0xfff;
2260 if (__predict_false(len > dmalen)) { 2260 if (__predict_false(len > dmalen)) {
2261 DPRINTF(("bad RXWI length %u > %u\n", len, dmalen)); 2261 DPRINTF(("bad RXWI length %u > %u\n", len, dmalen));
2262 return; 2262 return;
2263 } 2263 }
2264 /* Rx descriptor is located at the end */ 2264 /* Rx descriptor is located at the end */
2265 rxd = (struct rt2870_rxd *)(buf + dmalen); 2265 rxd = (struct rt2870_rxd *)(buf + dmalen);
2266 flags = le32toh(rxd->flags); 2266 flags = le32toh(rxd->flags);
2267 2267
2268 if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) { 2268 if (__predict_false(flags & (RT2860_RX_CRCERR | RT2860_RX_ICVERR))) {
2269 ifp->if_ierrors++; 2269 if_statinc(ifp, if_ierrors);
2270 return; 2270 return;
2271 } 2271 }
2272 2272
2273 wh = (struct ieee80211_frame *)(buf + rxwisize); 2273 wh = (struct ieee80211_frame *)(buf + rxwisize);
2274 2274
2275 if (__predict_false((flags & RT2860_RX_MICERR))) { 2275 if (__predict_false((flags & RT2860_RX_MICERR))) {
2276 /* report MIC failures to net80211 for TKIP */ 2276 /* report MIC failures to net80211 for TKIP */
2277 ieee80211_notify_michael_failure(ic, wh, 0/* XXX */); 2277 ieee80211_notify_michael_failure(ic, wh, 0/* XXX */);
2278 ifp->if_ierrors++; 2278 if_statinc(ifp, if_ierrors);
2279 return; 2279 return;
2280 } 2280 }
2281  2281
2282 if (flags & RT2860_RX_L2PAD) { 2282 if (flags & RT2860_RX_L2PAD) {
2283 u_int hdrlen = ieee80211_hdrspace(ic, wh); 2283 u_int hdrlen = ieee80211_hdrspace(ic, wh);
2284 memmove((uint8_t *)wh + 2, wh, hdrlen); 2284 memmove((uint8_t *)wh + 2, wh, hdrlen);
2285 wh = (struct ieee80211_frame *)((uint8_t *)wh + 2); 2285 wh = (struct ieee80211_frame *)((uint8_t *)wh + 2);
2286 } 2286 }
2287 2287
2288#ifdef RUN_HWCRYPTO 2288#ifdef RUN_HWCRYPTO
2289 if (wh->i_fc[1] & IEEE80211_FC1_WEP) { 2289 if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
2290 wh->i_fc[1] &= ~IEEE80211_FC1_WEP; 2290 wh->i_fc[1] &= ~IEEE80211_FC1_WEP;
2291 decrypted = 1; 2291 decrypted = 1;
2292 } 2292 }
2293#endif 2293#endif
2294 2294
2295 /* could use m_devget but net80211 wants contig mgmt frames */ 2295 /* could use m_devget but net80211 wants contig mgmt frames */
2296 MGETHDR(m, M_DONTWAIT, MT_DATA); 2296 MGETHDR(m, M_DONTWAIT, MT_DATA);
2297 if (__predict_false(m == NULL)) { 2297 if (__predict_false(m == NULL)) {
2298 ifp->if_ierrors++; 2298 if_statinc(ifp, if_ierrors);
2299 return; 2299 return;
2300 } 2300 }
2301 if (len > MHLEN) { 2301 if (len > MHLEN) {
2302 MCLGET(m, M_DONTWAIT); 2302 MCLGET(m, M_DONTWAIT);
2303 if (__predict_false(!(m->m_flags & M_EXT))) { 2303 if (__predict_false(!(m->m_flags & M_EXT))) {
2304 ifp->if_ierrors++; 2304 if_statinc(ifp, if_ierrors);
2305 m_freem(m); 2305 m_freem(m);
2306 return; 2306 return;
2307 } 2307 }
2308 } 2308 }
2309 /* finalize mbuf */ 2309 /* finalize mbuf */
2310 m_set_rcvif(m, ifp); 2310 m_set_rcvif(m, ifp);
2311 memcpy(mtod(m, void *), wh, len); 2311 memcpy(mtod(m, void *), wh, len);
2312 m->m_pkthdr.len = m->m_len = len; 2312 m->m_pkthdr.len = m->m_len = len;
2313 2313
2314 ant = run_maxrssi_chain(sc, rxwi); 2314 ant = run_maxrssi_chain(sc, rxwi);
2315 rssi = rxwi->rssi[ant]; 2315 rssi = rxwi->rssi[ant];
2316 2316
2317 if (__predict_false(sc->sc_drvbpf != NULL)) { 2317 if (__predict_false(sc->sc_drvbpf != NULL)) {
@@ -2454,33 +2454,33 @@ run_txeof(struct usbd_xfer *xfer, void * @@ -2454,33 +2454,33 @@ run_txeof(struct usbd_xfer *xfer, void *
2454 2454
2455 s = splnet(); 2455 s = splnet();
2456 txq->queued--; 2456 txq->queued--;
2457 sc->qfullmsk &= ~(1 << data->qid); 2457 sc->qfullmsk &= ~(1 << data->qid);
2458 2458
2459 if (__predict_false(status != USBD_NORMAL_COMPLETION)) { 2459 if (__predict_false(status != USBD_NORMAL_COMPLETION)) {
2460 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 2460 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
2461 return; 2461 return;
2462 2462
2463 DPRINTF(("%s: usb error on tx: %s\n", 2463 DPRINTF(("%s: usb error on tx: %s\n",
2464 device_xname(sc->sc_dev), usbd_errstr(status))); 2464 device_xname(sc->sc_dev), usbd_errstr(status)));
2465 if (status == USBD_STALLED) 2465 if (status == USBD_STALLED)
2466 usbd_clear_endpoint_stall_async(txq->pipeh); 2466 usbd_clear_endpoint_stall_async(txq->pipeh);
2467 ifp->if_oerrors++; 2467 if_statinc(ifp, if_oerrors);
2468 splx(s); 2468 splx(s);
2469 return; 2469 return;
2470 } 2470 }
2471 2471
2472 sc->sc_tx_timer = 0; 2472 sc->sc_tx_timer = 0;
2473 ifp->if_opackets++; 2473 if_statinc(ifp, if_opackets);
2474 ifp->if_flags &= ~IFF_OACTIVE; 2474 ifp->if_flags &= ~IFF_OACTIVE;
2475 run_start(ifp); 2475 run_start(ifp);
2476 splx(s); 2476 splx(s);
2477} 2477}
2478 2478
2479static int 2479static int
2480run_tx(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni) 2480run_tx(struct run_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
2481{ 2481{
2482 struct ieee80211com *ic = &sc->sc_ic; 2482 struct ieee80211com *ic = &sc->sc_ic;
2483 struct run_node *rn = (void *)ni; 2483 struct run_node *rn = (void *)ni;
2484 struct ieee80211_frame *wh; 2484 struct ieee80211_frame *wh;
2485#ifndef RUN_HWCRYPTO 2485#ifndef RUN_HWCRYPTO
2486 struct ieee80211_key *k; 2486 struct ieee80211_key *k;
@@ -2661,72 +2661,72 @@ run_start(struct ifnet *ifp) @@ -2661,72 +2661,72 @@ run_start(struct ifnet *ifp)
2661 ni = M_GETCTX(m, struct ieee80211_node *); 2661 ni = M_GETCTX(m, struct ieee80211_node *);
2662 M_CLEARCTX(m); 2662 M_CLEARCTX(m);
2663 goto sendit; 2663 goto sendit;
2664 } 2664 }
2665 if (ic->ic_state != IEEE80211_S_RUN) 2665 if (ic->ic_state != IEEE80211_S_RUN)
2666 break; 2666 break;
2667 2667
2668 /* encapsulate and send data frames */ 2668 /* encapsulate and send data frames */
2669 IFQ_DEQUEUE(&ifp->if_snd, m); 2669 IFQ_DEQUEUE(&ifp->if_snd, m);
2670 if (m == NULL) 2670 if (m == NULL)
2671 break; 2671 break;
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 2677
2678 eh = mtod(m, struct ether_header *); 2678 eh = mtod(m, struct ether_header *);
2679 ni = ieee80211_find_txnode(ic, eh->ether_dhost); 2679 ni = ieee80211_find_txnode(ic, eh->ether_dhost);
2680 if (ni == NULL) { 2680 if (ni == NULL) {
2681 m_freem(m); 2681 m_freem(m);
2682 ifp->if_oerrors++; 2682 if_statinc(ifp, if_oerrors);
2683 continue; 2683 continue;
2684 } 2684 }
2685 2685
2686 bpf_mtap(ifp, m, BPF_D_OUT); 2686 bpf_mtap(ifp, m, BPF_D_OUT);
2687 2687
2688 if ((m = ieee80211_encap(ic, m, ni)) == NULL) { 2688 if ((m = ieee80211_encap(ic, m, ni)) == NULL) {
2689 ieee80211_free_node(ni); 2689 ieee80211_free_node(ni);
2690 ifp->if_oerrors++; 2690 if_statinc(ifp, if_oerrors);
2691 continue; 2691 continue;
2692 } 2692 }
2693sendit: 2693sendit:
2694 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); 2694 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
2695 2695
2696 if (run_tx(sc, m, ni) != 0) { 2696 if (run_tx(sc, m, ni) != 0) {
2697 ieee80211_free_node(ni); 2697 ieee80211_free_node(ni);
2698 ifp->if_oerrors++; 2698 if_statinc(ifp, if_oerrors);
2699 continue; 2699 continue;
2700 } 2700 }
2701 2701
2702 sc->sc_tx_timer = 5; 2702 sc->sc_tx_timer = 5;
2703 ifp->if_timer = 1; 2703 ifp->if_timer = 1;
2704 } 2704 }
2705} 2705}
2706 2706
2707static void 2707static void
2708run_watchdog(struct ifnet *ifp) 2708run_watchdog(struct ifnet *ifp)
2709{ 2709{
2710 struct run_softc *sc = ifp->if_softc; 2710 struct run_softc *sc = ifp->if_softc;
2711 struct ieee80211com *ic = &sc->sc_ic; 2711 struct ieee80211com *ic = &sc->sc_ic;
2712 2712
2713 ifp->if_timer = 0; 2713 ifp->if_timer = 0;
2714 2714
2715 if (sc->sc_tx_timer > 0) { 2715 if (sc->sc_tx_timer > 0) {
2716 if (--sc->sc_tx_timer == 0) { 2716 if (--sc->sc_tx_timer == 0) {
2717 device_printf(sc->sc_dev, "device timeout\n"); 2717 device_printf(sc->sc_dev, "device timeout\n");
2718 /* run_init(ifp); XXX needs a process context! */ 2718 /* run_init(ifp); XXX needs a process context! */
2719 ifp->if_oerrors++; 2719 if_statinc(ifp, if_oerrors);
2720 return; 2720 return;
2721 } 2721 }
2722 ifp->if_timer = 1; 2722 ifp->if_timer = 1;
2723 } 2723 }
2724 2724
2725 ieee80211_watchdog(ic); 2725 ieee80211_watchdog(ic);
2726} 2726}
2727 2727
2728static int 2728static int
2729run_ioctl(struct ifnet *ifp, u_long cmd, void *data) 2729run_ioctl(struct ifnet *ifp, u_long cmd, void *data)
2730{ 2730{
2731 struct run_softc *sc = ifp->if_softc; 2731 struct run_softc *sc = ifp->if_softc;
2732 struct ieee80211com *ic = &sc->sc_ic; 2732 struct ieee80211com *ic = &sc->sc_ic;

cvs diff -r1.62 -r1.63 src/sys/dev/usb/if_smsc.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_smsc.c 2020/01/07 06:42:26 1.62
+++ src/sys/dev/usb/if_smsc.c 2020/01/29 06:35:28 1.63
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_smsc.c,v 1.62 2020/01/07 06:42:26 maxv Exp $ */ 1/* $NetBSD: if_smsc.c,v 1.63 2020/01/29 06:35:28 thorpej Exp $ */
2 2
3/* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */ 3/* $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
4/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */ 4/* $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
5/*- 5/*-
6 * Copyright (c) 2012 6 * Copyright (c) 2012
7 * Ben Gray <bgray@freebsd.org>. 7 * Ben Gray <bgray@freebsd.org>.
8 * All rights reserved. 8 * All rights reserved.
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.
@@ -51,27 +51,27 @@ @@ -51,27 +51,27 @@
51 * the H/W checksum will be incorrect, however the rx code compensates for this. 51 * the H/W checksum will be incorrect, however the rx code compensates for this.
52 * 52 *
53 * TX checksuming is more complicated, the device requires a special header to 53 * TX checksuming is more complicated, the device requires a special header to
54 * be prefixed onto the start of the frame which indicates the start and end 54 * be prefixed onto the start of the frame which indicates the start and end
55 * positions of the UDP or TCP frame. This requires the driver to manually 55 * positions of the UDP or TCP frame. This requires the driver to manually
56 * go through the packet data and decode the headers prior to sending. 56 * go through the packet data and decode the headers prior to sending.
57 * On Linux they generally provide cues to the location of the csum and the 57 * On Linux they generally provide cues to the location of the csum and the
58 * area to calculate it over, on FreeBSD we seem to have to do it all ourselves, 58 * area to calculate it over, on FreeBSD we seem to have to do it all ourselves,
59 * hence this is not as optimal and therefore h/w TX checksum is currently not 59 * hence this is not as optimal and therefore h/w TX checksum is currently not
60 * implemented. 60 * implemented.
61 */ 61 */
62 62
63#include <sys/cdefs.h> 63#include <sys/cdefs.h>
64__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.62 2020/01/07 06:42:26 maxv Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.63 2020/01/29 06:35:28 thorpej Exp $");
65 65
66#ifdef _KERNEL_OPT 66#ifdef _KERNEL_OPT
67#include "opt_usb.h" 67#include "opt_usb.h"
68#endif 68#endif
69 69
70#include <sys/param.h> 70#include <sys/param.h>
71 71
72#include <dev/usb/usbnet.h> 72#include <dev/usb/usbnet.h>
73#include <dev/usb/usbhist.h> 73#include <dev/usb/usbhist.h>
74 74
75#include <dev/usb/if_smscreg.h> 75#include <dev/usb/if_smscreg.h>
76 76
77#include "ioconf.h" 77#include "ioconf.h"
@@ -941,70 +941,70 @@ smsc_rx_loop(struct usbnet * un, struct  @@ -941,70 +941,70 @@ smsc_rx_loop(struct usbnet * un, struct
941 USMSCHIST_FUNC(); USMSCHIST_CALLED(); 941 USMSCHIST_FUNC(); USMSCHIST_CALLED();
942 struct smsc_softc * const sc = usbnet_softc(un); 942 struct smsc_softc * const sc = usbnet_softc(un);
943 struct ifnet *ifp = usbnet_ifp(un); 943 struct ifnet *ifp = usbnet_ifp(un);
944 uint8_t *buf = c->unc_buf; 944 uint8_t *buf = c->unc_buf;
945 945
946 usbnet_isowned_rx(un); 946 usbnet_isowned_rx(un);
947 947
948 DPRINTF("total_len %jd/0x%jx", total_len, total_len, 0, 0); 948 DPRINTF("total_len %jd/0x%jx", total_len, total_len, 0, 0);
949 while (total_len != 0) { 949 while (total_len != 0) {
950 uint32_t rxhdr; 950 uint32_t rxhdr;
951 if (total_len < sizeof(rxhdr)) { 951 if (total_len < sizeof(rxhdr)) {
952 DPRINTF("total_len %jd < sizeof(rxhdr) %jd", 952 DPRINTF("total_len %jd < sizeof(rxhdr) %jd",
953 total_len, sizeof(rxhdr), 0, 0); 953 total_len, sizeof(rxhdr), 0, 0);
954 ifp->if_ierrors++; 954 if_statinc(ifp, if_ierrors);
955 return; 955 return;
956 } 956 }
957 957
958 memcpy(&rxhdr, buf, sizeof(rxhdr)); 958 memcpy(&rxhdr, buf, sizeof(rxhdr));
959 rxhdr = le32toh(rxhdr); 959 rxhdr = le32toh(rxhdr);
960 buf += sizeof(rxhdr); 960 buf += sizeof(rxhdr);
961 total_len -= sizeof(rxhdr); 961 total_len -= sizeof(rxhdr);
962 962
963 if (rxhdr & SMSC_RX_STAT_COLLISION) 963 if (rxhdr & SMSC_RX_STAT_COLLISION)
964 ifp->if_collisions++; 964 if_statinc(ifp, if_collisions);
965 965
966 if (rxhdr & (SMSC_RX_STAT_ERROR 966 if (rxhdr & (SMSC_RX_STAT_ERROR
967 | SMSC_RX_STAT_LENGTH_ERROR 967 | SMSC_RX_STAT_LENGTH_ERROR
968 | SMSC_RX_STAT_MII_ERROR)) { 968 | SMSC_RX_STAT_MII_ERROR)) {
969 DPRINTF("rx error (hdr 0x%08jx)", rxhdr, 0, 0, 0); 969 DPRINTF("rx error (hdr 0x%08jx)", rxhdr, 0, 0, 0);
970 ifp->if_ierrors++; 970 if_statinc(ifp, if_ierrors);
971 return; 971 return;
972 } 972 }
973 973
974 uint16_t pktlen = (uint16_t)SMSC_RX_STAT_FRM_LENGTH(rxhdr); 974 uint16_t pktlen = (uint16_t)SMSC_RX_STAT_FRM_LENGTH(rxhdr);
975 DPRINTF("total_len %jd pktlen %jd rxhdr 0x%08jx", total_len, 975 DPRINTF("total_len %jd pktlen %jd rxhdr 0x%08jx", total_len,
976 pktlen, rxhdr, 0); 976 pktlen, rxhdr, 0);
977 977
978 if (pktlen < ETHER_HDR_LEN) { 978 if (pktlen < ETHER_HDR_LEN) {
979 DPRINTF("pktlen %jd < ETHER_HDR_LEN %jd", pktlen, 979 DPRINTF("pktlen %jd < ETHER_HDR_LEN %jd", pktlen,
980 ETHER_HDR_LEN, 0, 0); 980 ETHER_HDR_LEN, 0, 0);
981 ifp->if_ierrors++; 981 if_statinc(ifp, if_ierrors);
982 return; 982 return;
983 } 983 }
984 984
985 pktlen += ETHER_ALIGN; 985 pktlen += ETHER_ALIGN;
986 986
987 if (pktlen > MCLBYTES) { 987 if (pktlen > MCLBYTES) {
988 DPRINTF("pktlen %jd > MCLBYTES %jd", pktlen, MCLBYTES, 0, 988 DPRINTF("pktlen %jd > MCLBYTES %jd", pktlen, MCLBYTES, 0,
989 0); 989 0);
990 ifp->if_ierrors++; 990 if_statinc(ifp, if_ierrors);
991 return; 991 return;
992 } 992 }
993 993
994 if (pktlen > total_len) { 994 if (pktlen > total_len) {
995 DPRINTF("pktlen %jd > total_len %jd", pktlen, total_len, 995 DPRINTF("pktlen %jd > total_len %jd", pktlen, total_len,
996 0, 0); 996 0, 0);
997 ifp->if_ierrors++; 997 if_statinc(ifp, if_ierrors);
998 return; 998 return;
999 } 999 }
1000 1000
1001 uint8_t *pktbuf = buf + ETHER_ALIGN; 1001 uint8_t *pktbuf = buf + ETHER_ALIGN;
1002 size_t buflen = pktlen - ETHER_ALIGN; 1002 size_t buflen = pktlen - ETHER_ALIGN;
1003 int mbuf_flags = M_HASFCS; 1003 int mbuf_flags = M_HASFCS;
1004 int csum_flags = 0; 1004 int csum_flags = 0;
1005 uint16_t csum_data = 0; 1005 uint16_t csum_data = 0;
1006 1006
1007 KASSERT(pktlen < MCLBYTES); 1007 KASSERT(pktlen < MCLBYTES);
1008 1008
1009 /* Check if RX TCP/UDP checksumming is being offloaded */ 1009 /* Check if RX TCP/UDP checksumming is being offloaded */
1010 if (sc->sc_coe_ctrl & SMSC_COE_CTRL_RX_EN) { 1010 if (sc->sc_coe_ctrl & SMSC_COE_CTRL_RX_EN) {

cvs diff -r1.73 -r1.74 src/sys/dev/usb/if_udav.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_udav.c 2020/01/07 06:42:26 1.73
+++ src/sys/dev/usb/if_udav.c 2020/01/29 06:35:28 1.74
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_udav.c,v 1.73 2020/01/07 06:42:26 maxv Exp $ */ 1/* $NetBSD: if_udav.c,v 1.74 2020/01/29 06:35:28 thorpej Exp $ */
2/* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */ 2/* $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2003 5 * Copyright (c) 2003
6 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. 6 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -35,27 +35,27 @@ @@ -35,27 +35,27 @@
35 * DM9601(DAVICOM USB to Ethernet MAC Controller with Integrated 10/100 PHY) 35 * DM9601(DAVICOM USB to Ethernet MAC Controller with Integrated 10/100 PHY)
36 * The spec can be found at the following url. 36 * The spec can be found at the following url.
37 * http://www.davicom.com.tw/big5/download/Data%20Sheet/DM9601-DS-F01-062202s.pdf 37 * http://www.davicom.com.tw/big5/download/Data%20Sheet/DM9601-DS-F01-062202s.pdf
38 */ 38 */
39 39
40/* 40/*
41 * TODO: 41 * TODO:
42 * Interrupt Endpoint support 42 * Interrupt Endpoint support
43 * External PHYs 43 * External PHYs
44 * powerhook() support? 44 * powerhook() support?
45 */ 45 */
46 46
47#include <sys/cdefs.h> 47#include <sys/cdefs.h>
48__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.73 2020/01/07 06:42:26 maxv Exp $"); 48__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.74 2020/01/29 06:35:28 thorpej Exp $");
49 49
50#ifdef _KERNEL_OPT 50#ifdef _KERNEL_OPT
51#include "opt_usb.h" 51#include "opt_usb.h"
52#endif 52#endif
53 53
54#include <sys/param.h> 54#include <sys/param.h>
55 55
56#include <dev/usb/usbnet.h> 56#include <dev/usb/usbnet.h>
57#include <dev/usb/if_udavreg.h> 57#include <dev/usb/if_udavreg.h>
58 58
59/* Function declarations */ 59/* Function declarations */
60static int udav_match(device_t, cfdata_t, void *); 60static int udav_match(device_t, cfdata_t, void *);
61static void udav_attach(device_t, device_t, void *); 61static void udav_attach(device_t, device_t, void *);
@@ -703,34 +703,34 @@ udav_rx_loop(struct usbnet *un, struct u @@ -703,34 +703,34 @@ udav_rx_loop(struct usbnet *un, struct u
703 pktstat = *buf; 703 pktstat = *buf;
704 total_len -= sizeof(pktstat); 704 total_len -= sizeof(pktstat);
705 buf += sizeof(pktstat); 705 buf += sizeof(pktstat);
706 706
707 DPRINTF(("%s: RX Status: 0x%02x\n", device_xname(un->un_dev), pktstat)); 707 DPRINTF(("%s: RX Status: 0x%02x\n", device_xname(un->un_dev), pktstat));
708 708
709 pkt_len = UGETW(buf); 709 pkt_len = UGETW(buf);
710 total_len -= sizeof(pkt_len); 710 total_len -= sizeof(pkt_len);
711 buf += sizeof(pkt_len); 711 buf += sizeof(pkt_len);
712 712
713 DPRINTF(("%s: RX Length: 0x%02x\n", device_xname(un->un_dev), pkt_len)); 713 DPRINTF(("%s: RX Length: 0x%02x\n", device_xname(un->un_dev), pkt_len));
714 714
715 if (pktstat & UDAV_RSR_LCS) { 715 if (pktstat & UDAV_RSR_LCS) {
716 ifp->if_collisions++; 716 if_statinc(ifp, if_collisions);
717 return; 717 return;
718 } 718 }
719 719
720 if (pkt_len < sizeof(struct ether_header) || 720 if (pkt_len < sizeof(struct ether_header) ||
721 pkt_len > total_len || 721 pkt_len > total_len ||
722 (pktstat & UDAV_RSR_ERR)) { 722 (pktstat & UDAV_RSR_ERR)) {
723 ifp->if_ierrors++; 723 if_statinc(ifp, if_ierrors);
724 return; 724 return;
725 } 725 }
726 726
727 pkt_len -= ETHER_CRC_LEN; 727 pkt_len -= ETHER_CRC_LEN;
728 728
729 DPRINTF(("%s: Rx deliver: 0x%02x\n", device_xname(un->un_dev), pkt_len)); 729 DPRINTF(("%s: Rx deliver: 0x%02x\n", device_xname(un->un_dev), pkt_len));
730 730
731 usbnet_enqueue(un, buf, pkt_len, 0, 0, 0); 731 usbnet_enqueue(un, buf, pkt_len, 0, 0, 0);
732} 732}
733 733
734static int 734static int
735udav_ioctl_cb(struct ifnet *ifp, u_long cmd, void *data) 735udav_ioctl_cb(struct ifnet *ifp, u_long cmd, void *data)
736{ 736{

cvs diff -r1.10 -r1.11 src/sys/dev/usb/if_umb.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_umb.c 2019/12/17 04:54:36 1.10
+++ src/sys/dev/usb/if_umb.c 2020/01/29 06:35:28 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_umb.c,v 1.10 2019/12/17 04:54:36 christos Exp $ */ 1/* $NetBSD: if_umb.c,v 1.11 2020/01/29 06:35:28 thorpej Exp $ */
2/* $OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */ 2/* $OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2016 genua mbH 5 * Copyright (c) 2016 genua mbH
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@@ -16,27 +16,27 @@ @@ -16,27 +16,27 @@
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 * Mobile Broadband Interface Model specification: 22 * Mobile Broadband Interface Model specification:
23 * http://www.usb.org/developers/docs/devclass_docs/MBIM10Errata1_073013.zip 23 * http://www.usb.org/developers/docs/devclass_docs/MBIM10Errata1_073013.zip
24 * Compliance testing guide 24 * Compliance testing guide
25 * http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf 25 * http://www.usb.org/developers/docs/devclass_docs/MBIM-Compliance-1.0.pdf
26 */ 26 */
27 27
28#include <sys/cdefs.h> 28#include <sys/cdefs.h>
29__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.10 2019/12/17 04:54:36 christos Exp $"); 29__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.11 2020/01/29 06:35:28 thorpej Exp $");
30 30
31#ifdef _KERNEL_OPT 31#ifdef _KERNEL_OPT
32#include "opt_inet.h" 32#include "opt_inet.h"
33#endif 33#endif
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/device.h> 36#include <sys/device.h>
37#include <sys/endian.h> 37#include <sys/endian.h>
38#include <sys/kauth.h> 38#include <sys/kauth.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40#include <sys/kmem.h> 40#include <sys/kmem.h>
41#include <sys/mbuf.h> 41#include <sys/mbuf.h>
42#include <sys/rndsource.h> 42#include <sys/rndsource.h>
@@ -879,39 +879,38 @@ umb_output(struct ifnet *ifp, struct mbu @@ -879,39 +879,38 @@ umb_output(struct ifnet *ifp, struct mbu
879} 879}
880 880
881Static void 881Static void
882umb_input(struct ifnet *ifp, struct mbuf *m) 882umb_input(struct ifnet *ifp, struct mbuf *m)
883{ 883{
884 size_t pktlen = m->m_len; 884 size_t pktlen = m->m_len;
885 int s; 885 int s;
886 886
887 if ((ifp->if_flags & IFF_UP) == 0) { 887 if ((ifp->if_flags & IFF_UP) == 0) {
888 m_freem(m); 888 m_freem(m);
889 return; 889 return;
890 } 890 }
891 if (pktlen < sizeof(struct ip)) { 891 if (pktlen < sizeof(struct ip)) {
892 ifp->if_ierrors++; 892 if_statinc(ifp, if_ierrors);
893 DPRINTFN(4, "%s: dropping short packet (len %zd)\n", __func__, 893 DPRINTFN(4, "%s: dropping short packet (len %zd)\n", __func__,
894 pktlen); 894 pktlen);
895 m_freem(m); 895 m_freem(m);
896 return; 896 return;
897 } 897 }
898 s = splnet(); 898 s = splnet();
899 if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) { 899 if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) {
900 ifp->if_iqdrops++; 900 if_statinc(ifp, if_iqdrops);
901 m_freem(m); 901 m_freem(m);
902 } else { 902 } else {
903 ifp->if_ipackets++; 903 if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
904 ifp->if_ibytes += pktlen; 
905 } 904 }
906 splx(s); 905 splx(s);
907} 906}
908 907
909Static void 908Static void
910umb_start(struct ifnet *ifp) 909umb_start(struct ifnet *ifp)
911{ 910{
912 struct umb_softc *sc = ifp->if_softc; 911 struct umb_softc *sc = ifp->if_softc;
913 struct mbuf *m_head = NULL; 912 struct mbuf *m_head = NULL;
914 913
915 if (sc->sc_dying || (ifp->if_flags & IFF_OACTIVE)) 914 if (sc->sc_dying || (ifp->if_flags & IFF_OACTIVE))
916 return; 915 return;
917 916
@@ -929,27 +928,27 @@ umb_start(struct ifnet *ifp) @@ -929,27 +928,27 @@ umb_start(struct ifnet *ifp)
929 928
930 ifp->if_flags |= IFF_OACTIVE; 929 ifp->if_flags |= IFF_OACTIVE;
931 ifp->if_timer = (2 * umb_xfer_tout) / 1000; 930 ifp->if_timer = (2 * umb_xfer_tout) / 1000;
932} 931}
933 932
934Static void 933Static void
935umb_watchdog(struct ifnet *ifp) 934umb_watchdog(struct ifnet *ifp)
936{ 935{
937 struct umb_softc *sc = ifp->if_softc; 936 struct umb_softc *sc = ifp->if_softc;
938 937
939 if (sc->sc_dying) 938 if (sc->sc_dying)
940 return; 939 return;
941 940
942 ifp->if_oerrors++; 941 if_statinc(ifp, if_oerrors);
943 printf("%s: watchdog timeout\n", DEVNAM(sc)); 942 printf("%s: watchdog timeout\n", DEVNAM(sc));
944 usbd_abort_pipe(sc->sc_tx_pipe); 943 usbd_abort_pipe(sc->sc_tx_pipe);
945 return; 944 return;
946} 945}
947 946
948Static void 947Static void
949umb_statechg_timeout(void *arg) 948umb_statechg_timeout(void *arg)
950{ 949{
951 struct umb_softc *sc = arg; 950 struct umb_softc *sc = arg;
952 951
953 if (sc->sc_info.regstate != MBIM_REGSTATE_ROAMING || sc->sc_roaming) 952 if (sc->sc_info.regstate != MBIM_REGSTATE_ROAMING || sc->sc_roaming)
954 printf("%s: state change timeout\n",DEVNAM(sc)); 953 printf("%s: state change timeout\n",DEVNAM(sc));
955 usb_add_task(sc->sc_udev, &sc->sc_umb_task, USB_TASKQ_DRIVER); 954 usb_add_task(sc->sc_udev, &sc->sc_umb_task, USB_TASKQ_DRIVER);
@@ -1884,27 +1883,27 @@ umb_txeof(struct usbd_xfer *xfer, void * @@ -1884,27 +1883,27 @@ umb_txeof(struct usbd_xfer *xfer, void *
1884 struct umb_softc *sc = priv; 1883 struct umb_softc *sc = priv;
1885 struct ifnet *ifp = GET_IFP(sc); 1884 struct ifnet *ifp = GET_IFP(sc);
1886 int s; 1885 int s;
1887 1886
1888 s = splnet(); 1887 s = splnet();
1889 ifp->if_flags &= ~IFF_OACTIVE; 1888 ifp->if_flags &= ~IFF_OACTIVE;
1890 ifp->if_timer = 0; 1889 ifp->if_timer = 0;
1891 1890
1892 m_freem(sc->sc_tx_m); 1891 m_freem(sc->sc_tx_m);
1893 sc->sc_tx_m = NULL; 1892 sc->sc_tx_m = NULL;
1894 1893
1895 if (status != USBD_NORMAL_COMPLETION) { 1894 if (status != USBD_NORMAL_COMPLETION) {
1896 if (status != USBD_NOT_STARTED && status != USBD_CANCELLED) { 1895 if (status != USBD_NOT_STARTED && status != USBD_CANCELLED) {
1897 ifp->if_oerrors++; 1896 if_statinc(ifp, if_oerrors);
1898 DPRINTF("%s: tx error: %s\n", DEVNAM(sc), 1897 DPRINTF("%s: tx error: %s\n", DEVNAM(sc),
1899 usbd_errstr(status)); 1898 usbd_errstr(status));
1900 if (status == USBD_STALLED) 1899 if (status == USBD_STALLED)
1901 usbd_clear_endpoint_stall_async(sc->sc_tx_pipe); 1900 usbd_clear_endpoint_stall_async(sc->sc_tx_pipe);
1902 } 1901 }
1903 } 1902 }
1904 if (IFQ_IS_EMPTY(&ifp->if_snd) == 0) 1903 if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
1905 umb_start(ifp); 1904 umb_start(ifp);
1906 1905
1907 splx(s); 1906 splx(s);
1908} 1907}
1909 1908
1910Static void 1909Static void
@@ -2006,57 +2005,57 @@ umb_decap(struct umb_softc *sc, struct u @@ -2006,57 +2005,57 @@ umb_decap(struct umb_softc *sc, struct u
2006 dlen = UGETW(dgram16->wDatagramLen); 2005 dlen = UGETW(dgram16->wDatagramLen);
2007 doff = UGETW(dgram16->wDatagramIndex); 2006 doff = UGETW(dgram16->wDatagramIndex);
2008 break; 2007 break;
2009 case NCM_HDR32_SIG: 2008 case NCM_HDR32_SIG:
2010 if (ptroff + dgentryoff < sizeof(*dgram32)) 2009 if (ptroff + dgentryoff < sizeof(*dgram32))
2011 goto done; 2010 goto done;
2012 dgram32 = (struct ncm_pointer32_dgram *) 2011 dgram32 = (struct ncm_pointer32_dgram *)
2013 (buf + ptroff + dgentryoff); 2012 (buf + ptroff + dgentryoff);
2014 dgentryoff += sizeof(*dgram32); 2013 dgentryoff += sizeof(*dgram32);
2015 dlen = UGETDW(dgram32->dwDatagramLen); 2014 dlen = UGETDW(dgram32->dwDatagramLen);
2016 doff = UGETDW(dgram32->dwDatagramIndex); 2015 doff = UGETDW(dgram32->dwDatagramIndex);
2017 break; 2016 break;
2018 default: 2017 default:
2019 ifp->if_ierrors++; 2018 if_statinc(ifp, if_ierrors);
2020 goto done; 2019 goto done;
2021 } 2020 }
2022 2021
2023 /* Terminating zero entry */ 2022 /* Terminating zero entry */
2024 if (dlen == 0 || doff == 0) 2023 if (dlen == 0 || doff == 0)
2025 break; 2024 break;
2026 if (len < dlen + doff) { 2025 if (len < dlen + doff) {
2027 /* Skip giant datagram but continue processing */ 2026 /* Skip giant datagram but continue processing */
2028 DPRINTF("%s: datagram too large (%d @ off %d)\n", 2027 DPRINTF("%s: datagram too large (%d @ off %d)\n",
2029 DEVNAM(sc), dlen, doff); 2028 DEVNAM(sc), dlen, doff);
2030 continue; 2029 continue;
2031 } 2030 }
2032 2031
2033 dp = buf + doff; 2032 dp = buf + doff;
2034 DPRINTFN(3, "%s: decap %d bytes\n", DEVNAM(sc), dlen); 2033 DPRINTFN(3, "%s: decap %d bytes\n", DEVNAM(sc), dlen);
2035 m = m_devget(dp, dlen, 0, ifp); 2034 m = m_devget(dp, dlen, 0, ifp);
2036 if (m == NULL) { 2035 if (m == NULL) {
2037 ifp->if_iqdrops++; 2036 if_statinc(ifp, if_iqdrops);
2038 continue; 2037 continue;
2039 } 2038 }
2040 2039
2041 if_percpuq_enqueue((ifp)->if_percpuq, (m)); 2040 if_percpuq_enqueue((ifp)->if_percpuq, (m));
2042 } 2041 }
2043done: 2042done:
2044 splx(s); 2043 splx(s);
2045 return; 2044 return;
2046toosmall: 2045toosmall:
2047 DPRINTF("%s: packet too small (%d)\n", DEVNAM(sc), len); 2046 DPRINTF("%s: packet too small (%d)\n", DEVNAM(sc), len);
2048fail: 2047fail:
2049 ifp->if_ierrors++; 2048 if_statinc(ifp, if_ierrors);
2050 splx(s); 2049 splx(s);
2051} 2050}
2052 2051
2053Static usbd_status 2052Static usbd_status
2054umb_send_encap_command(struct umb_softc *sc, void *data, int len) 2053umb_send_encap_command(struct umb_softc *sc, void *data, int len)
2055{ 2054{
2056 struct usbd_xfer *xfer; 2055 struct usbd_xfer *xfer;
2057 usb_device_request_t req; 2056 usb_device_request_t req;
2058 char *buf; 2057 char *buf;
2059 2058
2060 if (len > sc->sc_ctrl_len) 2059 if (len > sc->sc_ctrl_len)
2061 return USBD_INVAL; 2060 return USBD_INVAL;
2062 2061

cvs diff -r1.27 -r1.28 src/sys/dev/usb/if_upgt.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_upgt.c 2020/01/15 08:20:13 1.27
+++ src/sys/dev/usb/if_upgt.c 2020/01/29 06:35:28 1.28
@@ -1,34 +1,34 @@ @@ -1,34 +1,34 @@
1/* $NetBSD: if_upgt.c,v 1.27 2020/01/15 08:20:13 skrll Exp $ */ 1/* $NetBSD: if_upgt.c,v 1.28 2020/01/29 06:35:28 thorpej Exp $ */
2/* $OpenBSD: if_upgt.c,v 1.49 2010/04/20 22:05:43 tedu Exp $ */ 2/* $OpenBSD: if_upgt.c,v 1.49 2010/04/20 22:05:43 tedu Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org> 5 * Copyright (c) 2007 Marcus Glocker <mglocker@openbsd.org>
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above 8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies. 9 * copyright notice and this permission notice appear in all copies.
10 * 10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */ 18 */
19 19
20#include <sys/cdefs.h> 20#include <sys/cdefs.h>
21__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.27 2020/01/15 08:20:13 skrll Exp $"); 21__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.28 2020/01/29 06:35:28 thorpej Exp $");
22 22
23#ifdef _KERNEL_OPT 23#ifdef _KERNEL_OPT
24#include "opt_usb.h" 24#include "opt_usb.h"
25#endif 25#endif
26 26
27#include <sys/param.h> 27#include <sys/param.h>
28#include <sys/callout.h> 28#include <sys/callout.h>
29#include <sys/device.h> 29#include <sys/device.h>
30#include <sys/errno.h> 30#include <sys/errno.h>
31#include <sys/kernel.h> 31#include <sys/kernel.h>
32#include <sys/kthread.h> 32#include <sys/kthread.h>
33#include <sys/mbuf.h> 33#include <sys/mbuf.h>
34#include <sys/proc.h> 34#include <sys/proc.h>
@@ -1481,27 +1481,27 @@ upgt_start(struct ifnet *ifp) @@ -1481,27 +1481,27 @@ upgt_start(struct ifnet *ifp)
1481 if (m != NULL) { 1481 if (m != NULL) {
1482 /* management frame */ 1482 /* management frame */
1483 IF_DEQUEUE(&ic->ic_mgtq, m); 1483 IF_DEQUEUE(&ic->ic_mgtq, m);
1484 1484
1485 ni = M_GETCTX(m, struct ieee80211_node *); 1485 ni = M_GETCTX(m, struct ieee80211_node *);
1486 M_CLEARCTX(m); 1486 M_CLEARCTX(m);
1487 1487
1488 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); 1488 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
1489 1489
1490 if ((data_tx->addr = upgt_mem_alloc(sc)) == 0) { 1490 if ((data_tx->addr = upgt_mem_alloc(sc)) == 0) {
1491 aprint_error_dev(sc->sc_dev, 1491 aprint_error_dev(sc->sc_dev,
1492 "no free prism memory\n"); 1492 "no free prism memory\n");
1493 m_freem(m); 1493 m_freem(m);
1494 ifp->if_oerrors++; 1494 if_statinc(ifp, if_oerrors);
1495 break; 1495 break;
1496 } 1496 }
1497 data_tx->ni = ni; 1497 data_tx->ni = ni;
1498 data_tx->m = m; 1498 data_tx->m = m;
1499 sc->tx_queued++; 1499 sc->tx_queued++;
1500 } else { 1500 } else {
1501 /* data frame */ 1501 /* data frame */
1502 if (ic->ic_state != IEEE80211_S_RUN) 1502 if (ic->ic_state != IEEE80211_S_RUN)
1503 break; 1503 break;
1504 1504
1505 IFQ_POLL(&ifp->if_snd, m); 1505 IFQ_POLL(&ifp->if_snd, m);
1506 if (m == NULL) 1506 if (m == NULL)
1507 break; 1507 break;
@@ -1523,27 +1523,27 @@ upgt_start(struct ifnet *ifp) @@ -1523,27 +1523,27 @@ upgt_start(struct ifnet *ifp)
1523 m = ieee80211_encap(ic, m, ni); 1523 m = ieee80211_encap(ic, m, ni);
1524 if (m == NULL) { 1524 if (m == NULL) {
1525 ieee80211_free_node(ni); 1525 ieee80211_free_node(ni);
1526 continue; 1526 continue;
1527 } 1527 }
1528 1528
1529 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); 1529 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
1530 1530
1531 if ((data_tx->addr = upgt_mem_alloc(sc)) == 0) { 1531 if ((data_tx->addr = upgt_mem_alloc(sc)) == 0) {
1532 aprint_error_dev(sc->sc_dev, 1532 aprint_error_dev(sc->sc_dev,
1533 "no free prism memory\n"); 1533 "no free prism memory\n");
1534 m_freem(m); 1534 m_freem(m);
1535 ieee80211_free_node(ni); 1535 ieee80211_free_node(ni);
1536 ifp->if_oerrors++; 1536 if_statinc(ifp, if_oerrors);
1537 break; 1537 break;
1538 } 1538 }
1539 data_tx->ni = ni; 1539 data_tx->ni = ni;
1540 data_tx->m = m; 1540 data_tx->m = m;
1541 sc->tx_queued++; 1541 sc->tx_queued++;
1542 } 1542 }
1543 } 1543 }
1544 1544
1545 if (sc->tx_queued > 0) { 1545 if (sc->tx_queued > 0) {
1546 DPRINTF(2, "%s: tx_queued=%d\n", 1546 DPRINTF(2, "%s: tx_queued=%d\n",
1547 device_xname(sc->sc_dev), sc->tx_queued); 1547 device_xname(sc->sc_dev), sc->tx_queued);
1548 /* process the TX queue in process context */ 1548 /* process the TX queue in process context */
1549 ifp->if_timer = 5; 1549 ifp->if_timer = 5;
@@ -1601,27 +1601,27 @@ upgt_tx_task(void *arg) @@ -1601,27 +1601,27 @@ upgt_tx_task(void *arg)
1601 1601
1602 /* 1602 /*
1603 * Software crypto. 1603 * Software crypto.
1604 */ 1604 */
1605 wh = mtod(m, struct ieee80211_frame *); 1605 wh = mtod(m, struct ieee80211_frame *);
1606 1606
1607 if (wh->i_fc[1] & IEEE80211_FC1_WEP) { 1607 if (wh->i_fc[1] & IEEE80211_FC1_WEP) {
1608 k = ieee80211_crypto_encap(ic, data_tx->ni, m); 1608 k = ieee80211_crypto_encap(ic, data_tx->ni, m);
1609 if (k == NULL) { 1609 if (k == NULL) {
1610 m_freem(m); 1610 m_freem(m);
1611 data_tx->m = NULL; 1611 data_tx->m = NULL;
1612 ieee80211_free_node(data_tx->ni); 1612 ieee80211_free_node(data_tx->ni);
1613 data_tx->ni = NULL; 1613 data_tx->ni = NULL;
1614 ifp->if_oerrors++; 1614 if_statinc(ifp, if_oerrors);
1615 break; 1615 break;
1616 } 1616 }
1617 1617
1618 /* in case packet header moved, reset pointer */ 1618 /* in case packet header moved, reset pointer */
1619 wh = mtod(m, struct ieee80211_frame *); 1619 wh = mtod(m, struct ieee80211_frame *);
1620 } 1620 }
1621 1621
1622 /* 1622 /*
1623 * Transmit the URB containing the TX data. 1623 * Transmit the URB containing the TX data.
1624 */ 1624 */
1625 memset(data_tx->buf, 0, sizeof(*mem) + sizeof(*txdesc)); 1625 memset(data_tx->buf, 0, sizeof(*mem) + sizeof(*txdesc));
1626 1626
1627 mem = (struct upgt_lmac_mem *)data_tx->buf; 1627 mem = (struct upgt_lmac_mem *)data_tx->buf;
@@ -1686,27 +1686,27 @@ upgt_tx_task(void *arg) @@ -1686,27 +1686,27 @@ upgt_tx_task(void *arg)
1686 ieee80211_free_node(data_tx->ni); 1686 ieee80211_free_node(data_tx->ni);
1687 data_tx->ni = NULL; 1687 data_tx->ni = NULL;
1688 1688
1689 DPRINTF(2, "%s: TX start data sending\n", 1689 DPRINTF(2, "%s: TX start data sending\n",
1690 device_xname(sc->sc_dev)); 1690 device_xname(sc->sc_dev));
1691 1691
1692 usbd_setup_xfer(data_tx->xfer, data_tx, data_tx->buf, len, 1692 usbd_setup_xfer(data_tx->xfer, data_tx, data_tx->buf, len,
1693 USBD_FORCE_SHORT_XFER, UPGT_USB_TIMEOUT, NULL); 1693 USBD_FORCE_SHORT_XFER, UPGT_USB_TIMEOUT, NULL);
1694 error = usbd_transfer(data_tx->xfer); 1694 error = usbd_transfer(data_tx->xfer);
1695 if (error != USBD_NORMAL_COMPLETION && 1695 if (error != USBD_NORMAL_COMPLETION &&
1696 error != USBD_IN_PROGRESS) { 1696 error != USBD_IN_PROGRESS) {
1697 aprint_error_dev(sc->sc_dev, 1697 aprint_error_dev(sc->sc_dev,
1698 "could not transmit TX data URB\n"); 1698 "could not transmit TX data URB\n");
1699 ifp->if_oerrors++; 1699 if_statinc(ifp, if_oerrors);
1700 break; 1700 break;
1701 } 1701 }
1702 1702
1703 DPRINTF(2, "%s: TX sent (%d bytes)\n", 1703 DPRINTF(2, "%s: TX sent (%d bytes)\n",
1704 device_xname(sc->sc_dev), len); 1704 device_xname(sc->sc_dev), len);
1705 } 1705 }
1706 1706
1707 splx(s); 1707 splx(s);
1708 1708
1709 /* 1709 /*
1710 * If we don't regulary read the device statistics, the RX queue 1710 * If we don't regulary read the device statistics, the RX queue
1711 * will stall. It's strange, but it works, so we keep reading 1711 * will stall. It's strange, but it works, so we keep reading
1712 * the statistics here. *shrug* 1712 * the statistics here. *shrug*
@@ -1725,27 +1725,27 @@ upgt_tx_done(struct upgt_softc *sc, uint @@ -1725,27 +1725,27 @@ upgt_tx_done(struct upgt_softc *sc, uint
1725 1725
1726 s = splnet(); 1726 s = splnet();
1727 1727
1728 desc = (struct upgt_lmac_tx_done_desc *)data; 1728 desc = (struct upgt_lmac_tx_done_desc *)data;
1729 1729
1730 for (i = 0; i < UPGT_TX_COUNT; i++) { 1730 for (i = 0; i < UPGT_TX_COUNT; i++) {
1731 struct upgt_data *data_tx = &sc->tx_data[i]; 1731 struct upgt_data *data_tx = &sc->tx_data[i];
1732 1732
1733 if (data_tx->addr == le32toh(desc->header2.reqid)) { 1733 if (data_tx->addr == le32toh(desc->header2.reqid)) {
1734 upgt_mem_free(sc, data_tx->addr); 1734 upgt_mem_free(sc, data_tx->addr);
1735 data_tx->addr = 0; 1735 data_tx->addr = 0;
1736 1736
1737 sc->tx_queued--; 1737 sc->tx_queued--;
1738 ifp->if_opackets++; 1738 if_statinc(ifp, if_opackets);
1739 1739
1740 DPRINTF(2, "%s: TX done: ", device_xname(sc->sc_dev)); 1740 DPRINTF(2, "%s: TX done: ", device_xname(sc->sc_dev));
1741 DPRINTF(2, "memaddr=0x%08x, status=0x%04x, rssi=%d, ", 1741 DPRINTF(2, "memaddr=0x%08x, status=0x%04x, rssi=%d, ",
1742 le32toh(desc->header2.reqid), 1742 le32toh(desc->header2.reqid),
1743 le16toh(desc->status), 1743 le16toh(desc->status),
1744 le16toh(desc->rssi)); 1744 le16toh(desc->rssi));
1745 DPRINTF(2, "seq=%d\n", le16toh(desc->seq)); 1745 DPRINTF(2, "seq=%d\n", le16toh(desc->seq));
1746 break; 1746 break;
1747 } 1747 }
1748 } 1748 }
1749 1749
1750 if (sc->tx_queued == 0) { 1750 if (sc->tx_queued == 0) {
1751 /* TX queued was processed, continue */ 1751 /* TX queued was processed, continue */
@@ -1847,27 +1847,27 @@ upgt_rx(struct upgt_softc *sc, uint8_t * @@ -1847,27 +1847,27 @@ upgt_rx(struct upgt_softc *sc, uint8_t *
1847 struct ieee80211_frame *wh; 1847 struct ieee80211_frame *wh;
1848 struct ieee80211_node *ni; 1848 struct ieee80211_node *ni;
1849 struct mbuf *m; 1849 struct mbuf *m;
1850 int s; 1850 int s;
1851 1851
1852 /* access RX packet descriptor */ 1852 /* access RX packet descriptor */
1853 rxdesc = (struct upgt_lmac_rx_desc *)data; 1853 rxdesc = (struct upgt_lmac_rx_desc *)data;
1854 1854
1855 /* create mbuf which is suitable for strict alignment archs */ 1855 /* create mbuf which is suitable for strict alignment archs */
1856 m = m_devget(rxdesc->data, pkglen, 0, ifp); 1856 m = m_devget(rxdesc->data, pkglen, 0, ifp);
1857 if (m == NULL) { 1857 if (m == NULL) {
1858 DPRINTF(1, "%s: could not create RX mbuf\n", 1858 DPRINTF(1, "%s: could not create RX mbuf\n",
1859 device_xname(sc->sc_dev)); 1859 device_xname(sc->sc_dev));
1860 ifp->if_ierrors++; 1860 if_statinc(ifp, if_ierrors);
1861 return; 1861 return;
1862 } 1862 }
1863 1863
1864 s = splnet(); 1864 s = splnet();
1865 1865
1866 if (sc->sc_drvbpf != NULL) { 1866 if (sc->sc_drvbpf != NULL) {
1867 struct upgt_rx_radiotap_header *tap = &sc->sc_rxtap; 1867 struct upgt_rx_radiotap_header *tap = &sc->sc_rxtap;
1868 1868
1869 tap->wr_flags = IEEE80211_RADIOTAP_F_FCS; 1869 tap->wr_flags = IEEE80211_RADIOTAP_F_FCS;
1870 tap->wr_rate = upgt_rx_rate(sc, rxdesc->rate); 1870 tap->wr_rate = upgt_rx_rate(sc, rxdesc->rate);
1871 tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq); 1871 tap->wr_chan_freq = htole16(ic->ic_curchan->ic_freq);
1872 tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags); 1872 tap->wr_chan_flags = htole16(ic->ic_curchan->ic_flags);
1873 tap->wr_antsignal = rxdesc->rssi; 1873 tap->wr_antsignal = rxdesc->rssi;

cvs diff -r1.69 -r1.70 src/sys/dev/usb/if_upl.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_upl.c 2020/01/07 06:42:26 1.69
+++ src/sys/dev/usb/if_upl.c 2020/01/29 06:35:28 1.70
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_upl.c,v 1.69 2020/01/07 06:42:26 maxv Exp $ */ 1/* $NetBSD: if_upl.c,v 1.70 2020/01/29 06:35:28 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000 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 Lennart Augustsson (lennart@augustsson.net) at 8 * by Lennart Augustsson (lennart@augustsson.net) at
9 * Carlstedt Research & Technology. 9 * Carlstedt Research & Technology.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE. 30 * POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33/* 33/*
34 * Prolific PL2301/PL2302 driver 34 * Prolific PL2301/PL2302 driver
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.69 2020/01/07 06:42:26 maxv Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.70 2020/01/29 06:35:28 thorpej Exp $");
39 39
40#ifdef _KERNEL_OPT 40#ifdef _KERNEL_OPT
41#include "opt_inet.h" 41#include "opt_inet.h"
42#include "opt_usb.h" 42#include "opt_usb.h"
43#endif 43#endif
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46 46
47#include <dev/usb/usbnet.h> 47#include <dev/usb/usbnet.h>
48 48
49#include <net/if_types.h> 49#include <net/if_types.h>
50 50
51#ifdef INET 51#ifdef INET
@@ -297,28 +297,27 @@ upl_output(struct ifnet *ifp, struct mbu @@ -297,28 +297,27 @@ upl_output(struct ifnet *ifp, struct mbu
297 */ 297 */
298 return if_transmit_lock(ifp, m); 298 return if_transmit_lock(ifp, m);
299} 299}
300 300
301static void 301static void
302upl_input(struct ifnet *ifp, struct mbuf *m) 302upl_input(struct ifnet *ifp, struct mbuf *m)
303{ 303{
304#ifdef INET 304#ifdef INET
305 size_t pktlen = m->m_len; 305 size_t pktlen = m->m_len;
306 int s; 306 int s;
307 307
308 s = splnet(); 308 s = splnet();
309 if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) { 309 if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) {
310 ifp->if_iqdrops++; 310 if_statinc(ifp, if_iqdrops);
311 m_freem(m); 311 m_freem(m);
312 } else { 312 } else {
313 ifp->if_ipackets++; 313 if_statadd2(ifp, if_ipackets, 1, if_ibytes, pktlen);
314 ifp->if_ibytes += pktlen; 
315 } 314 }
316 splx(s); 315 splx(s);
317#endif 316#endif
318} 317}
319 318
320#ifdef _MODULE 319#ifdef _MODULE
321#include "ioconf.c" 320#include "ioconf.c"
322#endif 321#endif
323 322
324USBNET_MODULE(upl) 323USBNET_MODULE(upl)

cvs diff -r1.61 -r1.62 src/sys/dev/usb/if_ural.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_ural.c 2019/12/01 08:27:54 1.61
+++ src/sys/dev/usb/if_ural.c 2020/01/29 06:35:28 1.62
@@ -1,40 +1,40 @@ @@ -1,40 +1,40 @@
1/* $NetBSD: if_ural.c,v 1.61 2019/12/01 08:27:54 maxv Exp $ */ 1/* $NetBSD: if_ural.c,v 1.62 2020/01/29 06:35:28 thorpej Exp $ */
2/* $FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $ */ 2/* $FreeBSD: /repoman/r/ncvs/src/sys/dev/usb/if_ural.c,v 1.40 2006/06/02 23:14:40 sam Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2005, 2006 5 * Copyright (c) 2005, 2006
6 * Damien Bergamini <damien.bergamini@free.fr> 6 * Damien Bergamini <damien.bergamini@free.fr>
7 * 7 *
8 * Permission to use, copy, modify, and distribute this software for any 8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above 9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies. 10 * copyright notice and this permission notice appear in all copies.
11 * 11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */ 19 */
20 20
21/*- 21/*-
22 * Ralink Technology RT2500USB chipset driver 22 * Ralink Technology RT2500USB chipset driver
23 * http://www.ralinktech.com/ 23 * http://www.ralinktech.com/
24 */ 24 */
25 25
26#include <sys/cdefs.h> 26#include <sys/cdefs.h>
27__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.61 2019/12/01 08:27:54 maxv Exp $"); 27__KERNEL_RCSID(0, "$NetBSD: if_ural.c,v 1.62 2020/01/29 06:35:28 thorpej Exp $");
28 28
29#ifdef _KERNEL_OPT 29#ifdef _KERNEL_OPT
30#include "opt_usb.h" 30#include "opt_usb.h"
31#endif 31#endif
32 32
33#include <sys/param.h> 33#include <sys/param.h>
34#include <sys/sockio.h> 34#include <sys/sockio.h>
35#include <sys/sysctl.h> 35#include <sys/sysctl.h>
36#include <sys/mbuf.h> 36#include <sys/mbuf.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <sys/socket.h> 38#include <sys/socket.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/conf.h> 40#include <sys/conf.h>
@@ -856,39 +856,39 @@ ural_txeof(struct usbd_xfer *xfer, void  @@ -856,39 +856,39 @@ ural_txeof(struct usbd_xfer *xfer, void
856 struct ifnet *ifp = &sc->sc_if; 856 struct ifnet *ifp = &sc->sc_if;
857 int s; 857 int s;
858 858
859 if (status != USBD_NORMAL_COMPLETION) { 859 if (status != USBD_NORMAL_COMPLETION) {
860 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 860 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
861 return; 861 return;
862 862
863 printf("%s: could not transmit buffer: %s\n", 863 printf("%s: could not transmit buffer: %s\n",
864 device_xname(sc->sc_dev), usbd_errstr(status)); 864 device_xname(sc->sc_dev), usbd_errstr(status));
865 865
866 if (status == USBD_STALLED) 866 if (status == USBD_STALLED)
867 usbd_clear_endpoint_stall_async(sc->sc_tx_pipeh); 867 usbd_clear_endpoint_stall_async(sc->sc_tx_pipeh);
868 868
869 ifp->if_oerrors++; 869 if_statinc(ifp, if_oerrors);
870 return; 870 return;
871 } 871 }
872 872
873 s = splnet(); 873 s = splnet();
874 874
875 m_freem(data->m); 875 m_freem(data->m);
876 data->m = NULL; 876 data->m = NULL;
877 ieee80211_free_node(data->ni); 877 ieee80211_free_node(data->ni);
878 data->ni = NULL; 878 data->ni = NULL;
879 879
880 sc->tx_queued--; 880 sc->tx_queued--;
881 ifp->if_opackets++; 881 if_statinc(ifp, if_opackets);
882 882
883 DPRINTFN(10, ("tx done\n")); 883 DPRINTFN(10, ("tx done\n"));
884 884
885 sc->sc_tx_timer = 0; 885 sc->sc_tx_timer = 0;
886 ifp->if_flags &= ~IFF_OACTIVE; 886 ifp->if_flags &= ~IFF_OACTIVE;
887 ural_start(ifp); 887 ural_start(ifp);
888 888
889 splx(s); 889 splx(s);
890} 890}
891 891
892Static void 892Static void
893ural_rxeof(struct usbd_xfer *xfer, void * priv, usbd_status status) 893ural_rxeof(struct usbd_xfer *xfer, void * priv, usbd_status status)
894{ 894{
@@ -906,53 +906,53 @@ ural_rxeof(struct usbd_xfer *xfer, void  @@ -906,53 +906,53 @@ ural_rxeof(struct usbd_xfer *xfer, void
906 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 906 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
907 return; 907 return;
908 908
909 if (status == USBD_STALLED) 909 if (status == USBD_STALLED)
910 usbd_clear_endpoint_stall_async(sc->sc_rx_pipeh); 910 usbd_clear_endpoint_stall_async(sc->sc_rx_pipeh);
911 goto skip; 911 goto skip;
912 } 912 }
913 913
914 usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL); 914 usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
915 915
916 if (len < RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN) { 916 if (len < RAL_RX_DESC_SIZE + IEEE80211_MIN_LEN) {
917 DPRINTF(("%s: xfer too short %d\n", device_xname(sc->sc_dev), 917 DPRINTF(("%s: xfer too short %d\n", device_xname(sc->sc_dev),
918 len)); 918 len));
919 ifp->if_ierrors++; 919 if_statinc(ifp, if_ierrors);
920 goto skip; 920 goto skip;
921 } 921 }
922 922
923 /* rx descriptor is located at the end */ 923 /* rx descriptor is located at the end */
924 desc = (struct ural_rx_desc *)(data->buf + len - RAL_RX_DESC_SIZE); 924 desc = (struct ural_rx_desc *)(data->buf + len - RAL_RX_DESC_SIZE);
925 925
926 if ((le32toh(desc->flags) & RAL_RX_PHY_ERROR) || 926 if ((le32toh(desc->flags) & RAL_RX_PHY_ERROR) ||
927 (le32toh(desc->flags) & RAL_RX_CRC_ERROR)) { 927 (le32toh(desc->flags) & RAL_RX_CRC_ERROR)) {
928 /* 928 /*
929 * This should not happen since we did not request to receive 929 * This should not happen since we did not request to receive
930 * those frames when we filled RAL_TXRX_CSR2. 930 * those frames when we filled RAL_TXRX_CSR2.
931 */ 931 */
932 DPRINTFN(5, ("PHY or CRC error\n")); 932 DPRINTFN(5, ("PHY or CRC error\n"));
933 ifp->if_ierrors++; 933 if_statinc(ifp, if_ierrors);
934 goto skip; 934 goto skip;
935 } 935 }
936 936
937 MGETHDR(mnew, M_DONTWAIT, MT_DATA); 937 MGETHDR(mnew, M_DONTWAIT, MT_DATA);
938 if (mnew == NULL) { 938 if (mnew == NULL) {
939 ifp->if_ierrors++; 939 if_statinc(ifp, if_ierrors);
940 goto skip; 940 goto skip;
941 } 941 }
942 942
943 MCLGET(mnew, M_DONTWAIT); 943 MCLGET(mnew, M_DONTWAIT);
944 if (!(mnew->m_flags & M_EXT)) { 944 if (!(mnew->m_flags & M_EXT)) {
945 ifp->if_ierrors++; 945 if_statinc(ifp, if_ierrors);
946 m_freem(mnew); 946 m_freem(mnew);
947 goto skip; 947 goto skip;
948 } 948 }
949 949
950 m = data->m; 950 m = data->m;
951 data->m = mnew; 951 data->m = mnew;
952 data->buf = mtod(data->m, uint8_t *); 952 data->buf = mtod(data->m, uint8_t *);
953 953
954 /* finalize mbuf */ 954 /* finalize mbuf */
955 m_set_rcvif(m, ifp); 955 m_set_rcvif(m, ifp);
956 m->m_pkthdr.len = m->m_len = (le32toh(desc->flags) >> 16) & 0xfff; 956 m->m_pkthdr.len = m->m_len = (le32toh(desc->flags) >> 16) & 0xfff;
957 m->m_flags |= M_HASFCS; /* h/w leaves FCS */ 957 m->m_flags |= M_HASFCS; /* h/w leaves FCS */
958 958
@@ -1390,49 +1390,49 @@ ural_start(struct ifnet *ifp) @@ -1390,49 +1390,49 @@ ural_start(struct ifnet *ifp)
1390 if (ni == NULL) { 1390 if (ni == NULL) {
1391 m_freem(m0); 1391 m_freem(m0);
1392 continue; 1392 continue;
1393 } 1393 }
1394 bpf_mtap(ifp, m0, BPF_D_OUT); 1394 bpf_mtap(ifp, m0, BPF_D_OUT);
1395 m0 = ieee80211_encap(ic, m0, ni); 1395 m0 = ieee80211_encap(ic, m0, ni);
1396 if (m0 == NULL) { 1396 if (m0 == NULL) {
1397 ieee80211_free_node(ni); 1397 ieee80211_free_node(ni);
1398 continue; 1398 continue;
1399 } 1399 }
1400 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); 1400 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
1401 if (ural_tx_data(sc, m0, ni) != 0) { 1401 if (ural_tx_data(sc, m0, ni) != 0) {
1402 ieee80211_free_node(ni); 1402 ieee80211_free_node(ni);
1403 ifp->if_oerrors++; 1403 if_statinc(ifp, if_oerrors);
1404 break; 1404 break;
1405 } 1405 }
1406 } 1406 }
1407 1407
1408 sc->sc_tx_timer = 5; 1408 sc->sc_tx_timer = 5;
1409 ifp->if_timer = 1; 1409 ifp->if_timer = 1;
1410 } 1410 }
1411} 1411}
1412 1412
1413Static void 1413Static void
1414ural_watchdog(struct ifnet *ifp) 1414ural_watchdog(struct ifnet *ifp)
1415{ 1415{
1416 struct ural_softc *sc = ifp->if_softc; 1416 struct ural_softc *sc = ifp->if_softc;
1417 struct ieee80211com *ic = &sc->sc_ic; 1417 struct ieee80211com *ic = &sc->sc_ic;
1418 1418
1419 ifp->if_timer = 0; 1419 ifp->if_timer = 0;
1420 1420
1421 if (sc->sc_tx_timer > 0) { 1421 if (sc->sc_tx_timer > 0) {
1422 if (--sc->sc_tx_timer == 0) { 1422 if (--sc->sc_tx_timer == 0) {
1423 printf("%s: device timeout\n", device_xname(sc->sc_dev)); 1423 printf("%s: device timeout\n", device_xname(sc->sc_dev));
1424 /*ural_init(sc); XXX needs a process context! */ 1424 /*ural_init(sc); XXX needs a process context! */
1425 ifp->if_oerrors++; 1425 if_statinc(ifp, if_oerrors);
1426 return; 1426 return;
1427 } 1427 }
1428 ifp->if_timer = 1; 1428 ifp->if_timer = 1;
1429 } 1429 }
1430 1430
1431 ieee80211_watchdog(ic); 1431 ieee80211_watchdog(ic);
1432} 1432}
1433 1433
1434/* 1434/*
1435 * This function allows for fast channel switching in monitor mode (used by 1435 * This function allows for fast channel switching in monitor mode (used by
1436 * net-mgmt/kismet). In IBSS mode, we must explicitly reset the interface to 1436 * net-mgmt/kismet). In IBSS mode, we must explicitly reset the interface to
1437 * generate a new beacon frame. 1437 * generate a new beacon frame.
1438 */ 1438 */
@@ -2331,27 +2331,27 @@ ural_amrr_update(struct usbd_xfer *xfer, @@ -2331,27 +2331,27 @@ ural_amrr_update(struct usbd_xfer *xfer,
2331 usbd_status status) 2331 usbd_status status)
2332{ 2332{
2333 struct ural_softc *sc = (struct ural_softc *)priv; 2333 struct ural_softc *sc = (struct ural_softc *)priv;
2334 struct ifnet *ifp = sc->sc_ic.ic_ifp; 2334 struct ifnet *ifp = sc->sc_ic.ic_ifp;
2335 2335
2336 if (status != USBD_NORMAL_COMPLETION) { 2336 if (status != USBD_NORMAL_COMPLETION) {
2337 printf("%s: could not retrieve Tx statistics - " 2337 printf("%s: could not retrieve Tx statistics - "
2338 "cancelling automatic rate control\n", 2338 "cancelling automatic rate control\n",
2339 device_xname(sc->sc_dev)); 2339 device_xname(sc->sc_dev));
2340 return; 2340 return;
2341 } 2341 }
2342 2342
2343 /* count TX retry-fail as Tx errors */ 2343 /* count TX retry-fail as Tx errors */
2344 ifp->if_oerrors += sc->sta[9]; 2344 if_statadd(ifp, if_oerrors, sc->sta[9]);
2345 2345
2346 sc->amn.amn_retrycnt = 2346 sc->amn.amn_retrycnt =
2347 sc->sta[7] + /* TX one-retry ok count */ 2347 sc->sta[7] + /* TX one-retry ok count */
2348 sc->sta[8] + /* TX more-retry ok count */ 2348 sc->sta[8] + /* TX more-retry ok count */
2349 sc->sta[9]; /* TX retry-fail count */ 2349 sc->sta[9]; /* TX retry-fail count */
2350 2350
2351 sc->amn.amn_txcnt = 2351 sc->amn.amn_txcnt =
2352 sc->amn.amn_retrycnt + 2352 sc->amn.amn_retrycnt +
2353 sc->sta[6]; /* TX no-retry ok count */ 2353 sc->sta[6]; /* TX no-retry ok count */
2354 2354
2355 ieee80211_amrr_choose(&sc->amrr, sc->sc_ic.ic_bss, &sc->amn); 2355 ieee80211_amrr_choose(&sc->amrr, sc->sc_ic.ic_bss, &sc->amn);
2356 2356
2357 callout_reset(&sc->sc_amrr_ch, hz, ural_amrr_timeout, sc); 2357 callout_reset(&sc->sc_amrr_ch, hz, ural_amrr_timeout, sc);