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


(thorpej)
diff -r1.34 -r1.35 src/sys/dev/usb/if_ure.c
diff -r1.72 -r1.73 src/sys/dev/usb/if_url.c
diff -r1.35 -r1.36 src/sys/dev/usb/if_urndis.c
diff -r1.20 -r1.21 src/sys/dev/usb/if_urtw.c
diff -r1.80 -r1.81 src/sys/dev/usb/if_urtwn.c
diff -r1.55 -r1.56 src/sys/dev/usb/if_zyd.c
diff -r1.31 -r1.32 src/sys/dev/usb/uhso.c
diff -r1.33 -r1.34 src/sys/dev/usb/usbnet.c

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

--- src/sys/dev/usb/if_ure.c 2020/01/07 06:42:26 1.34
+++ src/sys/dev/usb/if_ure.c 2020/01/29 06:39:07 1.35
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_ure.c,v 1.34 2020/01/07 06:42:26 maxv Exp $ */ 1/* $NetBSD: if_ure.c,v 1.35 2020/01/29 06:39:07 thorpej Exp $ */
2/* $OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $ */ 2/* $OpenBSD: if_ure.c,v 1.10 2018/11/02 21:32:30 jcs Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2015-2016 Kevin Lo <kevlo@FreeBSD.org> 5 * Copyright (c) 2015-2016 Kevin Lo <kevlo@FreeBSD.org>
6 * All rights reserved. 6 * 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
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE. 27 * SUCH DAMAGE.
28 */ 28 */
29 29
30/* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */ 30/* RealTek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.34 2020/01/07 06:42:26 maxv Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.35 2020/01/29 06:39:07 thorpej Exp $");
34 34
35#ifdef _KERNEL_OPT 35#ifdef _KERNEL_OPT
36#include "opt_usb.h" 36#include "opt_usb.h"
37#include "opt_inet.h" 37#include "opt_inet.h"
38#endif 38#endif
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/cprng.h> 41#include <sys/cprng.h>
42 42
43#include <net/route.h> 43#include <net/route.h>
44 44
45#include <dev/usb/usbnet.h> 45#include <dev/usb/usbnet.h>
46 46
@@ -997,40 +997,40 @@ static void @@ -997,40 +997,40 @@ static void
997ure_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len) 997ure_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len)
998{ 998{
999 struct ifnet *ifp = usbnet_ifp(un); 999 struct ifnet *ifp = usbnet_ifp(un);
1000 uint8_t *buf = c->unc_buf; 1000 uint8_t *buf = c->unc_buf;
1001 uint16_t pkt_len = 0; 1001 uint16_t pkt_len = 0;
1002 uint16_t pkt_count = 0; 1002 uint16_t pkt_count = 0;
1003 struct ure_rxpkt rxhdr; 1003 struct ure_rxpkt rxhdr;
1004 1004
1005 usbnet_isowned_rx(un); 1005 usbnet_isowned_rx(un);
1006 1006
1007 do { 1007 do {
1008 if (total_len < sizeof(rxhdr)) { 1008 if (total_len < sizeof(rxhdr)) {
1009 DPRINTF(("too few bytes left for a packet header\n")); 1009 DPRINTF(("too few bytes left for a packet header\n"));
1010 ifp->if_ierrors++; 1010 if_statinc(ifp, if_ierrors);
1011 return; 1011 return;
1012 } 1012 }
1013 1013
1014 buf += roundup(pkt_len, 8); 1014 buf += roundup(pkt_len, 8);
1015 1015
1016 memcpy(&rxhdr, buf, sizeof(rxhdr)); 1016 memcpy(&rxhdr, buf, sizeof(rxhdr));
1017 total_len -= sizeof(rxhdr); 1017 total_len -= sizeof(rxhdr);
1018 1018
1019 pkt_len = le32toh(rxhdr.ure_pktlen) & URE_RXPKT_LEN_MASK; 1019 pkt_len = le32toh(rxhdr.ure_pktlen) & URE_RXPKT_LEN_MASK;
1020 DPRINTFN(4, ("next packet is %d bytes\n", pkt_len)); 1020 DPRINTFN(4, ("next packet is %d bytes\n", pkt_len));
1021 if (pkt_len > total_len) { 1021 if (pkt_len > total_len) {
1022 DPRINTF(("not enough bytes left for next packet\n")); 1022 DPRINTF(("not enough bytes left for next packet\n"));
1023 ifp->if_ierrors++; 1023 if_statinc(ifp, if_ierrors);
1024 return; 1024 return;
1025 } 1025 }
1026 1026
1027 total_len -= roundup(pkt_len, 8); 1027 total_len -= roundup(pkt_len, 8);
1028 buf += sizeof(rxhdr); 1028 buf += sizeof(rxhdr);
1029 1029
1030 usbnet_enqueue(un, buf, pkt_len - ETHER_CRC_LEN, 1030 usbnet_enqueue(un, buf, pkt_len - ETHER_CRC_LEN,
1031 ure_rxcsum(ifp, &rxhdr), 0, 0); 1031 ure_rxcsum(ifp, &rxhdr), 0, 0);
1032 1032
1033 pkt_count++; 1033 pkt_count++;
1034  1034
1035 } while (total_len > 0); 1035 } while (total_len > 0);
1036 1036

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

--- src/sys/dev/usb/if_url.c 2020/01/07 06:42:26 1.72
+++ src/sys/dev/usb/if_url.c 2020/01/29 06:39:07 1.73
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_url.c,v 1.72 2020/01/07 06:42:26 maxv Exp $ */ 1/* $NetBSD: if_url.c,v 1.73 2020/01/29 06:39:07 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2001, 2002 4 * Copyright (c) 2001, 2002
5 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved. 5 * Shingo WATANABE <nabe@nabechan.org>. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -34,27 +34,27 @@ @@ -34,27 +34,27 @@
34 * The RTL8150L(Realtek USB to fast ethernet controller) spec can be found at 34 * The RTL8150L(Realtek USB to fast ethernet controller) spec can be found at
35 * ftp://ftp.realtek.com.tw/lancard/data_sheet/8150/8150v14.pdf 35 * ftp://ftp.realtek.com.tw/lancard/data_sheet/8150/8150v14.pdf
36 * ftp://152.104.125.40/lancard/data_sheet/8150/8150v14.pdf 36 * ftp://152.104.125.40/lancard/data_sheet/8150/8150v14.pdf
37 */ 37 */
38 38
39/* 39/*
40 * TODO: 40 * TODO:
41 * Interrupt Endpoint support 41 * Interrupt Endpoint support
42 * External PHYs 42 * External PHYs
43 * powerhook() support? 43 * powerhook() support?
44 */ 44 */
45 45
46#include <sys/cdefs.h> 46#include <sys/cdefs.h>
47__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.72 2020/01/07 06:42:26 maxv Exp $"); 47__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.73 2020/01/29 06:39:07 thorpej Exp $");
48 48
49#ifdef _KERNEL_OPT 49#ifdef _KERNEL_OPT
50#include "opt_inet.h" 50#include "opt_inet.h"
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 <net/if_ether.h> 56#include <net/if_ether.h>
57#ifdef INET 57#ifdef INET
58#include <netinet/in.h> 58#include <netinet/in.h>
59#include <netinet/if_inarp.h> 59#include <netinet/if_inarp.h>
60#endif 60#endif
@@ -566,42 +566,42 @@ url_tx_prepare(struct usbnet *un, struct @@ -566,42 +566,42 @@ url_tx_prepare(struct usbnet *un, struct
566} 566}
567 567
568static void 568static void
569url_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len) 569url_rx_loop(struct usbnet *un, struct usbnet_chain *c, uint32_t total_len)
570{ 570{
571 struct ifnet *ifp = usbnet_ifp(un); 571 struct ifnet *ifp = usbnet_ifp(un);
572 url_rxhdr_t rxhdr; 572 url_rxhdr_t rxhdr;
573 573
574 usbnet_isowned_rx(un); 574 usbnet_isowned_rx(un);
575 575
576 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev),__func__)); 576 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev),__func__));
577 577
578 if (total_len <= ETHER_CRC_LEN || total_len <= sizeof(rxhdr)) { 578 if (total_len <= ETHER_CRC_LEN || total_len <= sizeof(rxhdr)) {
579 ifp->if_ierrors++; 579 if_statinc(ifp, if_ierrors);
580 return; 580 return;
581 } 581 }
582 582
583 memcpy(&rxhdr, c->unc_buf + total_len - ETHER_CRC_LEN, sizeof(rxhdr)); 583 memcpy(&rxhdr, c->unc_buf + total_len - ETHER_CRC_LEN, sizeof(rxhdr));
584 584
585 DPRINTF(("%s: RX Status: %dbytes%s%s%s%s packets\n", 585 DPRINTF(("%s: RX Status: %dbytes%s%s%s%s packets\n",
586 device_xname(un->un_dev), 586 device_xname(un->un_dev),
587 UGETW(rxhdr) & URL_RXHDR_BYTEC_MASK, 587 UGETW(rxhdr) & URL_RXHDR_BYTEC_MASK,
588 UGETW(rxhdr) & URL_RXHDR_VALID_MASK ? ", Valid" : "", 588 UGETW(rxhdr) & URL_RXHDR_VALID_MASK ? ", Valid" : "",
589 UGETW(rxhdr) & URL_RXHDR_RUNTPKT_MASK ? ", Runt" : "", 589 UGETW(rxhdr) & URL_RXHDR_RUNTPKT_MASK ? ", Runt" : "",
590 UGETW(rxhdr) & URL_RXHDR_PHYPKT_MASK ? ", Physical match" : "", 590 UGETW(rxhdr) & URL_RXHDR_PHYPKT_MASK ? ", Physical match" : "",
591 UGETW(rxhdr) & URL_RXHDR_MCASTPKT_MASK ? ", Multicast" : "")); 591 UGETW(rxhdr) & URL_RXHDR_MCASTPKT_MASK ? ", Multicast" : ""));
592 592
593 if ((UGETW(rxhdr) & URL_RXHDR_VALID_MASK) == 0) { 593 if ((UGETW(rxhdr) & URL_RXHDR_VALID_MASK) == 0) {
594 ifp->if_ierrors++; 594 if_statinc(ifp, if_ierrors);
595 return; 595 return;
596 } 596 }
597 597
598 total_len -= ETHER_CRC_LEN; 598 total_len -= ETHER_CRC_LEN;
599 599
600 DPRINTF(("%s: %s: deliver %d\n", device_xname(un->un_dev), 600 DPRINTF(("%s: %s: deliver %d\n", device_xname(un->un_dev),
601 __func__, total_len)); 601 __func__, total_len));
602 usbnet_enqueue(un, c->unc_buf, total_len, 0, 0, 0); 602 usbnet_enqueue(un, c->unc_buf, total_len, 0, 0, 0);
603} 603}
604 604
605#if 0 605#if 0
606static void url_intr(void) 606static void url_intr(void)
607{ 607{

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

--- src/sys/dev/usb/if_urndis.c 2020/01/07 06:42:26 1.35
+++ src/sys/dev/usb/if_urndis.c 2020/01/29 06:39:07 1.36
@@ -1,37 +1,37 @@ @@ -1,37 +1,37 @@
1/* $NetBSD: if_urndis.c,v 1.35 2020/01/07 06:42:26 maxv Exp $ */ 1/* $NetBSD: if_urndis.c,v 1.36 2020/01/29 06:39:07 thorpej Exp $ */
2/* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */ 2/* $OpenBSD: if_urndis.c,v 1.31 2011/07/03 15:47:17 matthew Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2010 Jonathan Armani <armani@openbsd.org> 5 * Copyright (c) 2010 Jonathan Armani <armani@openbsd.org>
6 * Copyright (c) 2010 Fabien Romano <fabien@openbsd.org> 6 * Copyright (c) 2010 Fabien Romano <fabien@openbsd.org>
7 * Copyright (c) 2010 Michael Knudsen <mk@openbsd.org> 7 * Copyright (c) 2010 Michael Knudsen <mk@openbsd.org>
8 * All rights reserved. 8 * All rights reserved.
9 * 9 *
10 * Permission to use, copy, modify, and distribute this software for any 10 * Permission to use, copy, modify, and distribute this software for any
11 * purpose with or without fee is hereby granted, provided that the above 11 * purpose with or without fee is hereby granted, provided that the above
12 * copyright notice and this permission notice appear in all copies. 12 * copyright notice and this permission notice appear in all copies.
13 * 13 *
14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 14 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 15 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 16 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 17 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 18 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 19 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 20 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 */ 21 */
22 22
23#include <sys/cdefs.h> 23#include <sys/cdefs.h>
24__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.35 2020/01/07 06:42:26 maxv Exp $"); 24__KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.36 2020/01/29 06:39:07 thorpej Exp $");
25 25
26#ifdef _KERNEL_OPT 26#ifdef _KERNEL_OPT
27#include "opt_usb.h" 27#include "opt_usb.h"
28#endif 28#endif
29 29
30#include <sys/param.h> 30#include <sys/param.h>
31#include <sys/kmem.h> 31#include <sys/kmem.h>
32 32
33#include <dev/usb/usbnet.h> 33#include <dev/usb/usbnet.h>
34#include <dev/usb/usbdevs.h> 34#include <dev/usb/usbdevs.h>
35#include <dev/usb/usbcdc.h> 35#include <dev/usb/usbcdc.h>
36 36
37#include <dev/ic/rndisreg.h> 37#include <dev/ic/rndisreg.h>
@@ -810,27 +810,27 @@ urndis_rx_loop(struct usbnet * un, struc @@ -810,27 +810,27 @@ urndis_rx_loop(struct usbnet * un, struc
810 printf("%s: urndis_decap invalid data " 810 printf("%s: urndis_decap invalid data "
811 "len/offset/end_position(%u/%u/%u) -> " 811 "len/offset/end_position(%u/%u/%u) -> "
812 "go out of receive buffer limit %u\n", 812 "go out of receive buffer limit %u\n",
813 DEVNAME(un), 813 DEVNAME(un),
814 le32toh(msg->rm_datalen), 814 le32toh(msg->rm_datalen),
815 le32toh(msg->rm_dataoffset), 815 le32toh(msg->rm_dataoffset),
816 le32toh(msg->rm_dataoffset) + 816 le32toh(msg->rm_dataoffset) +
817 le32toh(msg->rm_datalen) + (uint32_t)RNDIS_HEADER_OFFSET, 817 le32toh(msg->rm_datalen) + (uint32_t)RNDIS_HEADER_OFFSET,
818 le32toh(msg->rm_len)); 818 le32toh(msg->rm_len));
819 return; 819 return;
820 } 820 }
821 821
822 if (le32toh(msg->rm_datalen) < sizeof(struct ether_header)) { 822 if (le32toh(msg->rm_datalen) < sizeof(struct ether_header)) {
823 ifp->if_ierrors++; 823 if_statinc(ifp, if_ierrors);
824 printf("%s: urndis_decap invalid ethernet size " 824 printf("%s: urndis_decap invalid ethernet size "
825 "%d < %zu\n", 825 "%d < %zu\n",
826 DEVNAME(un), 826 DEVNAME(un),
827 le32toh(msg->rm_datalen), 827 le32toh(msg->rm_datalen),
828 sizeof(struct ether_header)); 828 sizeof(struct ether_header));
829 return; 829 return;
830 } 830 }
831 831
832 usbnet_enqueue(un, 832 usbnet_enqueue(un,
833 ((char*)&msg->rm_dataoffset + le32toh(msg->rm_dataoffset)), 833 ((char*)&msg->rm_dataoffset + le32toh(msg->rm_dataoffset)),
834 le32toh(msg->rm_datalen), 0, 0, 0); 834 le32toh(msg->rm_datalen), 0, 0, 0);
835 835
836 offset += le32toh(msg->rm_len); 836 offset += le32toh(msg->rm_len);

cvs diff -r1.20 -r1.21 src/sys/dev/usb/if_urtw.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_urtw.c 2019/11/28 17:09:10 1.20
+++ src/sys/dev/usb/if_urtw.c 2020/01/29 06:39:07 1.21
@@ -1,35 +1,35 @@ @@ -1,35 +1,35 @@
1/* $NetBSD: if_urtw.c,v 1.20 2019/11/28 17:09:10 maxv Exp $ */ 1/* $NetBSD: if_urtw.c,v 1.21 2020/01/29 06:39:07 thorpej Exp $ */
2/* $OpenBSD: if_urtw.c,v 1.39 2011/07/03 15:47:17 matthew Exp $ */ 2/* $OpenBSD: if_urtw.c,v 1.39 2011/07/03 15:47:17 matthew Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2009 Martynas Venckus <martynas@openbsd.org> 5 * Copyright (c) 2009 Martynas Venckus <martynas@openbsd.org>
6 * Copyright (c) 2008 Weongyo Jeong <weongyo@FreeBSD.org> 6 * Copyright (c) 2008 Weongyo Jeong <weongyo@FreeBSD.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#include <sys/cdefs.h> 21#include <sys/cdefs.h>
22__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.20 2019/11/28 17:09:10 maxv Exp $"); 22__KERNEL_RCSID(0, "$NetBSD: if_urtw.c,v 1.21 2020/01/29 06:39:07 thorpej Exp $");
23 23
24#ifdef _KERNEL_OPT 24#ifdef _KERNEL_OPT
25#include "opt_usb.h" 25#include "opt_usb.h"
26#endif 26#endif
27 27
28#include <sys/param.h> 28#include <sys/param.h>
29#include <sys/sockio.h> 29#include <sys/sockio.h>
30#include <sys/proc.h> 30#include <sys/proc.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/callout.h> 35#include <sys/callout.h>
@@ -2479,46 +2479,46 @@ urtw_start(struct ifnet *ifp) @@ -2479,46 +2479,46 @@ urtw_start(struct ifnet *ifp)
2479 m_freem(m0); 2479 m_freem(m0);
2480 continue; 2480 continue;
2481 } 2481 }
2482 bpf_mtap(ifp, m0, BPF_D_OUT); 2482 bpf_mtap(ifp, m0, BPF_D_OUT);
2483 m0 = ieee80211_encap(ic, m0, ni); 2483 m0 = ieee80211_encap(ic, m0, ni);
2484 if (m0 == NULL) { 2484 if (m0 == NULL) {
2485 ieee80211_free_node(ni); 2485 ieee80211_free_node(ni);
2486 continue; 2486 continue;
2487 } 2487 }
2488 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); 2488 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
2489 if (urtw_tx_start(sc, ni, m0, URTW_PRIORITY_NORMAL) 2489 if (urtw_tx_start(sc, ni, m0, URTW_PRIORITY_NORMAL)
2490 != 0) { 2490 != 0) {
2491 ieee80211_free_node(ni); 2491 ieee80211_free_node(ni);
2492 ifp->if_oerrors++; 2492 if_statinc(ifp, if_oerrors);
2493 break; 2493 break;
2494 } 2494 }
2495 } 2495 }
2496 sc->sc_txtimer = 5; 2496 sc->sc_txtimer = 5;
2497 ifp->if_timer = 1; 2497 ifp->if_timer = 1;
2498 } 2498 }
2499} 2499}
2500 2500
2501static void 2501static void
2502urtw_watchdog(struct ifnet *ifp) 2502urtw_watchdog(struct ifnet *ifp)
2503{ 2503{
2504 struct urtw_softc *sc = ifp->if_softc; 2504 struct urtw_softc *sc = ifp->if_softc;
2505 2505
2506 ifp->if_timer = 0; 2506 ifp->if_timer = 0;
2507 2507
2508 if (sc->sc_txtimer > 0) { 2508 if (sc->sc_txtimer > 0) {
2509 if (--sc->sc_txtimer == 0) { 2509 if (--sc->sc_txtimer == 0) {
2510 printf("%s: device timeout\n", device_xname(sc->sc_dev)); 2510 printf("%s: device timeout\n", device_xname(sc->sc_dev));
2511 ifp->if_oerrors++; 2511 if_statinc(ifp, if_oerrors);
2512 return; 2512 return;
2513 } 2513 }
2514 ifp->if_timer = 1; 2514 ifp->if_timer = 1;
2515 } 2515 }
2516 2516
2517 ieee80211_watchdog(&sc->sc_ic); 2517 ieee80211_watchdog(&sc->sc_ic);
2518} 2518}
2519 2519
2520static void 2520static void
2521urtw_txeof_low(struct usbd_xfer *xfer, void *priv, 2521urtw_txeof_low(struct usbd_xfer *xfer, void *priv,
2522 usbd_status status) 2522 usbd_status status)
2523{ 2523{
2524 struct urtw_tx_data *data = priv; 2524 struct urtw_tx_data *data = priv;
@@ -2527,37 +2527,37 @@ urtw_txeof_low(struct usbd_xfer *xfer, v @@ -2527,37 +2527,37 @@ urtw_txeof_low(struct usbd_xfer *xfer, v
2527 struct ifnet *ifp = ic->ic_ifp; 2527 struct ifnet *ifp = ic->ic_ifp;
2528 int s; 2528 int s;
2529 2529
2530 if (status != USBD_NORMAL_COMPLETION) { 2530 if (status != USBD_NORMAL_COMPLETION) {
2531 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 2531 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
2532 return; 2532 return;
2533 2533
2534 printf("%s: could not transmit buffer: %s\n", 2534 printf("%s: could not transmit buffer: %s\n",
2535 device_xname(sc->sc_dev), usbd_errstr(status)); 2535 device_xname(sc->sc_dev), usbd_errstr(status));
2536 2536
2537 if (status == USBD_STALLED) 2537 if (status == USBD_STALLED)
2538 usbd_clear_endpoint_stall_async(sc->sc_txpipe_low); 2538 usbd_clear_endpoint_stall_async(sc->sc_txpipe_low);
2539 2539
2540 ifp->if_oerrors++; 2540 if_statinc(ifp, if_oerrors);
2541 return; 2541 return;
2542 } 2542 }
2543 2543
2544 s = splnet(); 2544 s = splnet();
2545 2545
2546 ieee80211_free_node(data->ni); 2546 ieee80211_free_node(data->ni);
2547 data->ni = NULL; 2547 data->ni = NULL;
2548 2548
2549 sc->sc_txtimer = 0; 2549 sc->sc_txtimer = 0;
2550 ifp->if_opackets++; 2550 if_statinc(ifp, if_opackets);
2551 2551
2552 sc->sc_tx_queued[URTW_PRIORITY_LOW]--; 2552 sc->sc_tx_queued[URTW_PRIORITY_LOW]--;
2553 ifp->if_flags &= ~IFF_OACTIVE; 2553 ifp->if_flags &= ~IFF_OACTIVE;
2554 urtw_start(ifp); 2554 urtw_start(ifp);
2555 2555
2556 splx(s); 2556 splx(s);
2557} 2557}
2558 2558
2559static void 2559static void
2560urtw_txeof_normal(struct usbd_xfer *xfer, void *priv, 2560urtw_txeof_normal(struct usbd_xfer *xfer, void *priv,
2561 usbd_status status) 2561 usbd_status status)
2562{ 2562{
2563 struct urtw_tx_data *data = priv; 2563 struct urtw_tx_data *data = priv;
@@ -2566,37 +2566,37 @@ urtw_txeof_normal(struct usbd_xfer *xfer @@ -2566,37 +2566,37 @@ urtw_txeof_normal(struct usbd_xfer *xfer
2566 struct ifnet *ifp = ic->ic_ifp; 2566 struct ifnet *ifp = ic->ic_ifp;
2567 int s; 2567 int s;
2568 2568
2569 if (status != USBD_NORMAL_COMPLETION) { 2569 if (status != USBD_NORMAL_COMPLETION) {
2570 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 2570 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
2571 return; 2571 return;
2572 2572
2573 printf("%s: could not transmit buffer: %s\n", 2573 printf("%s: could not transmit buffer: %s\n",
2574 device_xname(sc->sc_dev), usbd_errstr(status)); 2574 device_xname(sc->sc_dev), usbd_errstr(status));
2575 2575
2576 if (status == USBD_STALLED) 2576 if (status == USBD_STALLED)
2577 usbd_clear_endpoint_stall_async(sc->sc_txpipe_normal); 2577 usbd_clear_endpoint_stall_async(sc->sc_txpipe_normal);
2578 2578
2579 ifp->if_oerrors++; 2579 if_statinc(ifp, if_oerrors);
2580 return; 2580 return;
2581 } 2581 }
2582 2582
2583 s = splnet(); 2583 s = splnet();
2584 2584
2585 ieee80211_free_node(data->ni); 2585 ieee80211_free_node(data->ni);
2586 data->ni = NULL; 2586 data->ni = NULL;
2587 2587
2588 sc->sc_txtimer = 0; 2588 sc->sc_txtimer = 0;
2589 ifp->if_opackets++; 2589 if_statinc(ifp, if_opackets);
2590 2590
2591 sc->sc_tx_queued[URTW_PRIORITY_NORMAL]--; 2591 sc->sc_tx_queued[URTW_PRIORITY_NORMAL]--;
2592 ifp->if_flags &= ~IFF_OACTIVE; 2592 ifp->if_flags &= ~IFF_OACTIVE;
2593 urtw_start(ifp); 2593 urtw_start(ifp);
2594 2594
2595 splx(s); 2595 splx(s);
2596} 2596}
2597 2597
2598static int 2598static int
2599urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0, 2599urtw_tx_start(struct urtw_softc *sc, struct ieee80211_node *ni, struct mbuf *m0,
2600 int prior) 2600 int prior)
2601{ 2601{
2602 struct ieee80211com *ic = &sc->sc_ic; 2602 struct ieee80211com *ic = &sc->sc_ic;
@@ -3063,81 +3063,81 @@ urtw_rxeof(struct usbd_xfer *xfer, void  @@ -3063,81 +3063,81 @@ urtw_rxeof(struct usbd_xfer *xfer, void
3063 struct ifnet *ifp = ic->ic_ifp; 3063 struct ifnet *ifp = ic->ic_ifp;
3064 struct ieee80211_frame *wh; 3064 struct ieee80211_frame *wh;
3065 struct ieee80211_node *ni; 3065 struct ieee80211_node *ni;
3066 struct mbuf *m, *mnew; 3066 struct mbuf *m, *mnew;
3067 uint8_t *desc, quality, rate; 3067 uint8_t *desc, quality, rate;
3068 int actlen, flen, len, rssi, s; 3068 int actlen, flen, len, rssi, s;
3069 3069
3070 if (status != USBD_NORMAL_COMPLETION) { 3070 if (status != USBD_NORMAL_COMPLETION) {
3071 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 3071 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
3072 return; 3072 return;
3073 3073
3074 if (status == USBD_STALLED) 3074 if (status == USBD_STALLED)
3075 usbd_clear_endpoint_stall_async(sc->sc_rxpipe); 3075 usbd_clear_endpoint_stall_async(sc->sc_rxpipe);
3076 ifp->if_ierrors++; 3076 if_statinc(ifp, if_ierrors);
3077 goto skip; 3077 goto skip;
3078 } 3078 }
3079 3079
3080 usbd_get_xfer_status(xfer, NULL, NULL, &actlen, NULL); 3080 usbd_get_xfer_status(xfer, NULL, NULL, &actlen, NULL);
3081 if (actlen < URTW_MIN_RXBUFSZ) { 3081 if (actlen < URTW_MIN_RXBUFSZ) {
3082 ifp->if_ierrors++; 3082 if_statinc(ifp, if_ierrors);
3083 goto skip; 3083 goto skip;
3084 } 3084 }
3085 3085
3086 if (sc->sc_hwrev & URTW_HWREV_8187) 3086 if (sc->sc_hwrev & URTW_HWREV_8187)
3087 /* 4 dword and 4 byte CRC */ 3087 /* 4 dword and 4 byte CRC */
3088 len = actlen - (4 * 4); 3088 len = actlen - (4 * 4);
3089 else 3089 else
3090 /* 5 dword and 4 byte CRC */ 3090 /* 5 dword and 4 byte CRC */
3091 len = actlen - (4 * 5); 3091 len = actlen - (4 * 5);
3092 3092
3093 desc = data->buf + len; 3093 desc = data->buf + len;
3094 flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff); 3094 flen = ((desc[1] & 0x0f) << 8) + (desc[0] & 0xff);
3095 if (flen > actlen) { 3095 if (flen > actlen) {
3096 ifp->if_ierrors++; 3096 if_statinc(ifp, if_ierrors);
3097 goto skip; 3097 goto skip;
3098 } 3098 }
3099 3099
3100 rate = (desc[2] & 0xf0) >> 4; 3100 rate = (desc[2] & 0xf0) >> 4;
3101 if (sc->sc_hwrev & URTW_HWREV_8187) { 3101 if (sc->sc_hwrev & URTW_HWREV_8187) {
3102 quality = desc[4] & 0xff; 3102 quality = desc[4] & 0xff;
3103 rssi = (desc[6] & 0xfe) >> 1; 3103 rssi = (desc[6] & 0xfe) >> 1;
3104 3104
3105 /* XXX correct? */ 3105 /* XXX correct? */
3106 if (!urtw_isbmode(rate)) { 3106 if (!urtw_isbmode(rate)) {
3107 rssi = (rssi > 90) ? 90 : ((rssi < 25) ? 25 : rssi); 3107 rssi = (rssi > 90) ? 90 : ((rssi < 25) ? 25 : rssi);
3108 rssi = ((90 - rssi) * 100) / 65; 3108 rssi = ((90 - rssi) * 100) / 65;
3109 } else { 3109 } else {
3110 rssi = (rssi > 90) ? 95 : ((rssi < 30) ? 30 : rssi); 3110 rssi = (rssi > 90) ? 95 : ((rssi < 30) ? 30 : rssi);
3111 rssi = ((95 - rssi) * 100) / 65; 3111 rssi = ((95 - rssi) * 100) / 65;
3112 } 3112 }
3113 } else { 3113 } else {
3114 quality = desc[12]; 3114 quality = desc[12];
3115 rssi = 14 - desc[14] / 2; 3115 rssi = 14 - desc[14] / 2;
3116 } 3116 }
3117 3117
3118 MGETHDR(mnew, M_DONTWAIT, MT_DATA); 3118 MGETHDR(mnew, M_DONTWAIT, MT_DATA);
3119 if (mnew == NULL) { 3119 if (mnew == NULL) {
3120 printf("%s: could not allocate rx mbuf\n", 3120 printf("%s: could not allocate rx mbuf\n",
3121 device_xname(sc->sc_dev)); 3121 device_xname(sc->sc_dev));
3122 ifp->if_ierrors++; 3122 if_statinc(ifp, if_ierrors);
3123 goto skip; 3123 goto skip;
3124 } 3124 }
3125 MCLGET(mnew, M_DONTWAIT); 3125 MCLGET(mnew, M_DONTWAIT);
3126 if (!(mnew->m_flags & M_EXT)) { 3126 if (!(mnew->m_flags & M_EXT)) {
3127 printf("%s: could not allocate rx mbuf cluster\n", 3127 printf("%s: could not allocate rx mbuf cluster\n",
3128 device_xname(sc->sc_dev)); 3128 device_xname(sc->sc_dev));
3129 m_freem(mnew); 3129 m_freem(mnew);
3130 ifp->if_ierrors++; 3130 if_statinc(ifp, if_ierrors);
3131 goto skip; 3131 goto skip;
3132 } 3132 }
3133 3133
3134 m = data->m; 3134 m = data->m;
3135 data->m = mnew; 3135 data->m = mnew;
3136 data->buf = mtod(mnew, uint8_t *); 3136 data->buf = mtod(mnew, uint8_t *);
3137 3137
3138 /* finalize mbuf */ 3138 /* finalize mbuf */
3139 m_set_rcvif(m, ifp); 3139 m_set_rcvif(m, ifp);
3140 m->m_pkthdr.len = m->m_len = flen - 4; 3140 m->m_pkthdr.len = m->m_len = flen - 4;
3141 3141
3142 s = splnet(); 3142 s = splnet();
3143 3143

cvs diff -r1.80 -r1.81 src/sys/dev/usb/if_urtwn.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_urtwn.c 2020/01/15 08:20:13 1.80
+++ src/sys/dev/usb/if_urtwn.c 2020/01/29 06:39:07 1.81
@@ -1,41 +1,41 @@ @@ -1,41 +1,41 @@
1/* $NetBSD: if_urtwn.c,v 1.80 2020/01/15 08:20:13 skrll Exp $ */ 1/* $NetBSD: if_urtwn.c,v 1.81 2020/01/29 06:39:07 thorpej Exp $ */
2/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi Exp $ */ 2/* $OpenBSD: if_urtwn.c,v 1.42 2015/02/10 23:25:46 mpi 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) 2014 Kevin Lo <kevlo@FreeBSD.org> 6 * Copyright (c) 2014 Kevin Lo <kevlo@FreeBSD.org>
7 * Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au> 7 * Copyright (c) 2016 Nathanial Sloss <nathanialsloss@yahoo.com.au>
8 * 8 *
9 * Permission to use, copy, modify, and distribute this software for any 9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above 10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies. 11 * copyright notice and this permission notice appear in all copies.
12 * 12 *
13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 13 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 19 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 */ 20 */
21 21
22/*- 22/*-
23 * Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU 23 * Driver for Realtek RTL8188CE-VAU/RTL8188CUS/RTL8188EU/RTL8188RU/RTL8192CU
24 * RTL8192EU. 24 * RTL8192EU.
25 */ 25 */
26 26
27#include <sys/cdefs.h> 27#include <sys/cdefs.h>
28__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.80 2020/01/15 08:20:13 skrll Exp $"); 28__KERNEL_RCSID(0, "$NetBSD: if_urtwn.c,v 1.81 2020/01/29 06:39:07 thorpej Exp $");
29 29
30#ifdef _KERNEL_OPT 30#ifdef _KERNEL_OPT
31#include "opt_inet.h" 31#include "opt_inet.h"
32#include "opt_usb.h" 32#include "opt_usb.h"
33#endif 33#endif
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/sockio.h> 36#include <sys/sockio.h>
37#include <sys/sysctl.h> 37#include <sys/sysctl.h>
38#include <sys/mbuf.h> 38#include <sys/mbuf.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40#include <sys/socket.h> 40#include <sys/socket.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
@@ -2370,77 +2370,77 @@ urtwn_rx_frame(struct urtwn_softc *sc, u @@ -2370,77 +2370,77 @@ urtwn_rx_frame(struct urtwn_softc *sc, u
2370 URTWNHIST_FUNC(); 2370 URTWNHIST_FUNC();
2371 URTWNHIST_CALLARGS("buf=%jp, pktlen=%#jd", (uintptr_t)buf, pktlen, 0, 0); 2371 URTWNHIST_CALLARGS("buf=%jp, pktlen=%#jd", (uintptr_t)buf, pktlen, 0, 0);
2372 2372
2373 stat = (struct r92c_rx_desc_usb *)buf; 2373 stat = (struct r92c_rx_desc_usb *)buf;
2374 rxdw0 = le32toh(stat->rxdw0); 2374 rxdw0 = le32toh(stat->rxdw0);
2375 rxdw3 = le32toh(stat->rxdw3); 2375 rxdw3 = le32toh(stat->rxdw3);
2376 2376
2377 if (__predict_false(rxdw0 & (R92C_RXDW0_CRCERR | R92C_RXDW0_ICVERR))) { 2377 if (__predict_false(rxdw0 & (R92C_RXDW0_CRCERR | R92C_RXDW0_ICVERR))) {
2378 /* 2378 /*
2379 * This should not happen since we setup our Rx filter 2379 * This should not happen since we setup our Rx filter
2380 * to not receive these frames. 2380 * to not receive these frames.
2381 */ 2381 */
2382 DPRINTFN(DBG_RX, "CRC error", 0, 0, 0, 0); 2382 DPRINTFN(DBG_RX, "CRC error", 0, 0, 0, 0);
2383 ifp->if_ierrors++; 2383 if_statinc(ifp, if_ierrors);
2384 return; 2384 return;
2385 } 2385 }
2386 /* 2386 /*
2387 * XXX: This will drop most control packets. Do we really 2387 * XXX: This will drop most control packets. Do we really
2388 * want this in IEEE80211_M_MONITOR mode? 2388 * want this in IEEE80211_M_MONITOR mode?
2389 */ 2389 */
2390// if (__predict_false(pktlen < (int)sizeof(*wh))) { 2390// if (__predict_false(pktlen < (int)sizeof(*wh))) {
2391 if (__predict_false(pktlen < (int)sizeof(struct ieee80211_frame_ack))) { 2391 if (__predict_false(pktlen < (int)sizeof(struct ieee80211_frame_ack))) {
2392 DPRINTFN(DBG_RX, "packet too short %jd", pktlen, 0, 0, 0); 2392 DPRINTFN(DBG_RX, "packet too short %jd", pktlen, 0, 0, 0);
2393 ic->ic_stats.is_rx_tooshort++; 2393 ic->ic_stats.is_rx_tooshort++;
2394 ifp->if_ierrors++; 2394 if_statinc(ifp, if_ierrors);
2395 return; 2395 return;
2396 } 2396 }
2397 if (__predict_false(pktlen > MCLBYTES)) { 2397 if (__predict_false(pktlen > MCLBYTES)) {
2398 DPRINTFN(DBG_RX, "packet too big %jd", pktlen, 0, 0, 0); 2398 DPRINTFN(DBG_RX, "packet too big %jd", pktlen, 0, 0, 0);
2399 ifp->if_ierrors++; 2399 if_statinc(ifp, if_ierrors);
2400 return; 2400 return;
2401 } 2401 }
2402 2402
2403 rate = MS(rxdw3, R92C_RXDW3_RATE); 2403 rate = MS(rxdw3, R92C_RXDW3_RATE);
2404 infosz = MS(rxdw0, R92C_RXDW0_INFOSZ) * 8; 2404 infosz = MS(rxdw0, R92C_RXDW0_INFOSZ) * 8;
2405 2405
2406 /* Get RSSI from PHY status descriptor if present. */ 2406 /* Get RSSI from PHY status descriptor if present. */
2407 if (infosz != 0 && (rxdw0 & R92C_RXDW0_PHYST)) { 2407 if (infosz != 0 && (rxdw0 & R92C_RXDW0_PHYST)) {
2408 if (!ISSET(sc->chip, URTWN_CHIP_92C)) 2408 if (!ISSET(sc->chip, URTWN_CHIP_92C))
2409 rssi = urtwn_r88e_get_rssi(sc, rate, &stat[1]); 2409 rssi = urtwn_r88e_get_rssi(sc, rate, &stat[1]);
2410 else 2410 else
2411 rssi = urtwn_get_rssi(sc, rate, &stat[1]); 2411 rssi = urtwn_get_rssi(sc, rate, &stat[1]);
2412 /* Update our average RSSI. */ 2412 /* Update our average RSSI. */
2413 urtwn_update_avgrssi(sc, rate, rssi); 2413 urtwn_update_avgrssi(sc, rate, rssi);
2414 } 2414 }
2415 2415
2416 DPRINTFN(DBG_RX, "Rx frame len=%jd rate=%jd infosz=%jd rssi=%jd", 2416 DPRINTFN(DBG_RX, "Rx frame len=%jd rate=%jd infosz=%jd rssi=%jd",
2417 pktlen, rate, infosz, rssi); 2417 pktlen, rate, infosz, rssi);
2418 2418
2419 MGETHDR(m, M_DONTWAIT, MT_DATA); 2419 MGETHDR(m, M_DONTWAIT, MT_DATA);
2420 if (__predict_false(m == NULL)) { 2420 if (__predict_false(m == NULL)) {
2421 aprint_error_dev(sc->sc_dev, "couldn't allocate rx mbuf\n"); 2421 aprint_error_dev(sc->sc_dev, "couldn't allocate rx mbuf\n");
2422 ic->ic_stats.is_rx_nobuf++; 2422 ic->ic_stats.is_rx_nobuf++;
2423 ifp->if_ierrors++; 2423 if_statinc(ifp, if_ierrors);
2424 return; 2424 return;
2425 } 2425 }
2426 if (pktlen > (int)MHLEN) { 2426 if (pktlen > (int)MHLEN) {
2427 MCLGET(m, M_DONTWAIT); 2427 MCLGET(m, M_DONTWAIT);
2428 if (__predict_false(!(m->m_flags & M_EXT))) { 2428 if (__predict_false(!(m->m_flags & M_EXT))) {
2429 aprint_error_dev(sc->sc_dev, 2429 aprint_error_dev(sc->sc_dev,
2430 "couldn't allocate rx mbuf cluster\n"); 2430 "couldn't allocate rx mbuf cluster\n");
2431 m_freem(m); 2431 m_freem(m);
2432 ic->ic_stats.is_rx_nobuf++; 2432 ic->ic_stats.is_rx_nobuf++;
2433 ifp->if_ierrors++; 2433 if_statinc(ifp, if_ierrors);
2434 return; 2434 return;
2435 } 2435 }
2436 } 2436 }
2437 2437
2438 /* Finalize mbuf. */ 2438 /* Finalize mbuf. */
2439 m_set_rcvif(m, ifp); 2439 m_set_rcvif(m, ifp);
2440 wh = (struct ieee80211_frame *)((uint8_t *)&stat[1] + infosz); 2440 wh = (struct ieee80211_frame *)((uint8_t *)&stat[1] + infosz);
2441 memcpy(mtod(m, uint8_t *), wh, pktlen); 2441 memcpy(mtod(m, uint8_t *), wh, pktlen);
2442 m->m_pkthdr.len = m->m_len = pktlen; 2442 m->m_pkthdr.len = m->m_len = pktlen;
2443 2443
2444 s = splnet(); 2444 s = splnet();
2445 if (__predict_false(sc->sc_drvbpf != NULL)) { 2445 if (__predict_false(sc->sc_drvbpf != NULL)) {
2446 struct urtwn_rx_radiotap_header *tap = &sc->sc_rxtap; 2446 struct urtwn_rx_radiotap_header *tap = &sc->sc_rxtap;
@@ -2588,33 +2588,33 @@ urtwn_txeof(struct usbd_xfer *xfer, void @@ -2588,33 +2588,33 @@ urtwn_txeof(struct usbd_xfer *xfer, void
2588 mutex_exit(&sc->sc_tx_mtx); 2588 mutex_exit(&sc->sc_tx_mtx);
2589 2589
2590 s = splnet(); 2590 s = splnet();
2591 sc->tx_timer = 0; 2591 sc->tx_timer = 0;
2592 ifp->if_flags &= ~IFF_OACTIVE; 2592 ifp->if_flags &= ~IFF_OACTIVE;
2593 2593
2594 if (__predict_false(status != USBD_NORMAL_COMPLETION)) { 2594 if (__predict_false(status != USBD_NORMAL_COMPLETION)) {
2595 if (status != USBD_NOT_STARTED && status != USBD_CANCELLED) { 2595 if (status != USBD_NOT_STARTED && status != USBD_CANCELLED) {
2596 if (status == USBD_STALLED) { 2596 if (status == USBD_STALLED) {
2597 struct usbd_pipe *pipe = sc->tx_pipe[pidx]; 2597 struct usbd_pipe *pipe = sc->tx_pipe[pidx];
2598 usbd_clear_endpoint_stall_async(pipe); 2598 usbd_clear_endpoint_stall_async(pipe);
2599 } 2599 }
2600 printf("ERROR1\n"); 2600 printf("ERROR1\n");
2601 ifp->if_oerrors++; 2601 if_statinc(ifp, if_oerrors);
2602 } 2602 }
2603 splx(s); 2603 splx(s);
2604 return; 2604 return;
2605 } 2605 }
2606 2606
2607 ifp->if_opackets++; 2607 if_statinc(ifp, if_opackets);
2608 urtwn_start(ifp); 2608 urtwn_start(ifp);
2609 splx(s); 2609 splx(s);
2610 2610
2611} 2611}
2612 2612
2613static int 2613static int
2614urtwn_tx(struct urtwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni, 2614urtwn_tx(struct urtwn_softc *sc, struct mbuf *m, struct ieee80211_node *ni,
2615 struct urtwn_tx_data *data) 2615 struct urtwn_tx_data *data)
2616{ 2616{
2617 struct ieee80211com *ic = &sc->sc_ic; 2617 struct ieee80211com *ic = &sc->sc_ic;
2618 struct ieee80211_frame *wh; 2618 struct ieee80211_frame *wh;
2619 struct ieee80211_key *k = NULL; 2619 struct ieee80211_key *k = NULL;
2620 struct r92c_tx_desc_usb *txd; 2620 struct r92c_tx_desc_usb *txd;
@@ -2881,78 +2881,78 @@ urtwn_start(struct ifnet *ifp) @@ -2881,78 +2881,78 @@ urtwn_start(struct ifnet *ifp)
2881 } 2881 }
2882 data = urtwn_get_tx_data(sc, sc->ac2idx[qid]); 2882 data = urtwn_get_tx_data(sc, sc->ac2idx[qid]);
2883 2883
2884 if (data == NULL) { 2884 if (data == NULL) {
2885 ifp->if_flags |= IFF_OACTIVE; 2885 ifp->if_flags |= IFF_OACTIVE;
2886 DPRINTFN(DBG_TX, "empty tx_free_list", 0, 0, 0, 0); 2886 DPRINTFN(DBG_TX, "empty tx_free_list", 0, 0, 0, 0);
2887 return; 2887 return;
2888 } 2888 }
2889 IFQ_DEQUEUE(&ifp->if_snd, m); 2889 IFQ_DEQUEUE(&ifp->if_snd, m);
2890 2890
2891 if (m->m_len < (int)sizeof(*eh) && 2891 if (m->m_len < (int)sizeof(*eh) &&
2892 (m = m_pullup(m, sizeof(*eh))) == NULL) { 2892 (m = m_pullup(m, sizeof(*eh))) == NULL) {
2893 printf("ERROR6\n"); 2893 printf("ERROR6\n");
2894 ifp->if_oerrors++; 2894 if_statinc(ifp, if_oerrors);
2895 continue; 2895 continue;
2896 } 2896 }
2897 eh = mtod(m, struct ether_header *); 2897 eh = mtod(m, struct ether_header *);
2898 ni = ieee80211_find_txnode(ic, eh->ether_dhost); 2898 ni = ieee80211_find_txnode(ic, eh->ether_dhost);
2899 if (ni == NULL) { 2899 if (ni == NULL) {
2900 m_freem(m); 2900 m_freem(m);
2901 printf("ERROR5\n"); 2901 printf("ERROR5\n");
2902 ifp->if_oerrors++; 2902 if_statinc(ifp, if_oerrors);
2903 continue; 2903 continue;
2904 } 2904 }
2905 2905
2906 bpf_mtap(ifp, m, BPF_D_OUT); 2906 bpf_mtap(ifp, m, BPF_D_OUT);
2907 2907
2908 if ((m = ieee80211_encap(ic, m, ni)) == NULL) { 2908 if ((m = ieee80211_encap(ic, m, ni)) == NULL) {
2909 ieee80211_free_node(ni); 2909 ieee80211_free_node(ni);
2910 printf("ERROR4\n"); 2910 printf("ERROR4\n");
2911 ifp->if_oerrors++; 2911 if_statinc(ifp, if_oerrors);
2912 continue; 2912 continue;
2913 } 2913 }
2914 sendit: 2914 sendit:
2915 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT); 2915 bpf_mtap3(ic->ic_rawbpf, m, BPF_D_OUT);
2916 2916
2917 if (urtwn_tx(sc, m, ni, data) != 0) { 2917 if (urtwn_tx(sc, m, ni, data) != 0) {
2918 m_freem(m); 2918 m_freem(m);
2919 ieee80211_free_node(ni); 2919 ieee80211_free_node(ni);
2920 printf("ERROR3\n"); 2920 printf("ERROR3\n");
2921 ifp->if_oerrors++; 2921 if_statinc(ifp, if_oerrors);
2922 continue; 2922 continue;
2923 } 2923 }
2924 m_freem(m); 2924 m_freem(m);
2925 ieee80211_free_node(ni); 2925 ieee80211_free_node(ni);
2926 sc->tx_timer = 5; 2926 sc->tx_timer = 5;
2927 ifp->if_timer = 1; 2927 ifp->if_timer = 1;
2928 } 2928 }
2929} 2929}
2930 2930
2931static void 2931static void
2932urtwn_watchdog(struct ifnet *ifp) 2932urtwn_watchdog(struct ifnet *ifp)
2933{ 2933{
2934 struct urtwn_softc *sc = ifp->if_softc; 2934 struct urtwn_softc *sc = ifp->if_softc;
2935 2935
2936 URTWNHIST_FUNC(); URTWNHIST_CALLED(); 2936 URTWNHIST_FUNC(); URTWNHIST_CALLED();
2937 2937
2938 ifp->if_timer = 0; 2938 ifp->if_timer = 0;
2939 2939
2940 if (sc->tx_timer > 0) { 2940 if (sc->tx_timer > 0) {
2941 if (--sc->tx_timer == 0) { 2941 if (--sc->tx_timer == 0) {
2942 aprint_error_dev(sc->sc_dev, "device timeout\n"); 2942 aprint_error_dev(sc->sc_dev, "device timeout\n");
2943 /* urtwn_init(ifp); XXX needs a process context! */ 2943 /* urtwn_init(ifp); XXX needs a process context! */
2944 printf("ERROR2\n"); 2944 printf("ERROR2\n");
2945 ifp->if_oerrors++; 2945 if_statinc(ifp, if_oerrors);
2946 return; 2946 return;
2947 } 2947 }
2948 ifp->if_timer = 1; 2948 ifp->if_timer = 1;
2949 } 2949 }
2950 ieee80211_watchdog(&sc->sc_ic); 2950 ieee80211_watchdog(&sc->sc_ic);
2951} 2951}
2952 2952
2953static int 2953static int
2954urtwn_ioctl(struct ifnet *ifp, u_long cmd, void *data) 2954urtwn_ioctl(struct ifnet *ifp, u_long cmd, void *data)
2955{ 2955{
2956 struct urtwn_softc *sc = ifp->if_softc; 2956 struct urtwn_softc *sc = ifp->if_softc;
2957 struct ieee80211com *ic = &sc->sc_ic; 2957 struct ieee80211com *ic = &sc->sc_ic;
2958 int s, error = 0; 2958 int s, error = 0;

cvs diff -r1.55 -r1.56 src/sys/dev/usb/if_zyd.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_zyd.c 2020/01/15 08:21:00 1.55
+++ src/sys/dev/usb/if_zyd.c 2020/01/29 06:39:07 1.56
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */ 1/* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */
2/* $NetBSD: if_zyd.c,v 1.55 2020/01/15 08:21:00 skrll Exp $ */ 2/* $NetBSD: if_zyd.c,v 1.56 2020/01/29 06:39:07 thorpej Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> 5 * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr>
6 * Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de> 6 * Copyright (c) 2006 by Florian Stoehr <ich@florian-stoehr.de>
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 * ZyDAS ZD1211/ZD1211B USB WLAN driver. 22 * ZyDAS ZD1211/ZD1211B USB WLAN driver.
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.55 2020/01/15 08:21:00 skrll Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.56 2020/01/29 06:39:07 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/proc.h> 34#include <sys/proc.h>
35#include <sys/mbuf.h> 35#include <sys/mbuf.h>
36#include <sys/kernel.h> 36#include <sys/kernel.h>
37#include <sys/kmem.h> 37#include <sys/kmem.h>
38#include <sys/socket.h> 38#include <sys/socket.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
@@ -1847,27 +1847,27 @@ zyd_intr(struct usbd_xfer *xfer, void *  @@ -1847,27 +1847,27 @@ zyd_intr(struct usbd_xfer *xfer, void *
1847 * retry statistics. In BSS mode, this node is the AP we're 1847 * retry statistics. In BSS mode, this node is the AP we're
1848 * associated to so no lookup is actually needed. 1848 * associated to so no lookup is actually needed.
1849 */ 1849 */
1850 if (ic->ic_opmode != IEEE80211_M_STA) { 1850 if (ic->ic_opmode != IEEE80211_M_STA) {
1851 ni = ieee80211_find_node(&ic->ic_scan, retry->macaddr); 1851 ni = ieee80211_find_node(&ic->ic_scan, retry->macaddr);
1852 if (ni == NULL) 1852 if (ni == NULL)
1853 return; /* just ignore */ 1853 return; /* just ignore */
1854 } else 1854 } else
1855 ni = ic->ic_bss; 1855 ni = ic->ic_bss;
1856 1856
1857 ((struct zyd_node *)ni)->amn.amn_retrycnt++; 1857 ((struct zyd_node *)ni)->amn.amn_retrycnt++;
1858 1858
1859 if (le16toh(retry->count) & 0x100) 1859 if (le16toh(retry->count) & 0x100)
1860 ifp->if_oerrors++; /* too many retries */ 1860 if_statinc(ifp, if_oerrors);
1861 1861
1862 } else if (le16toh(cmd->code) == ZYD_NOTIF_IORD) { 1862 } else if (le16toh(cmd->code) == ZYD_NOTIF_IORD) {
1863 struct rq *rqp; 1863 struct rq *rqp;
1864 1864
1865 if (le16toh(*(uint16_t *)cmd->data) == ZYD_CR_INTERRUPT) 1865 if (le16toh(*(uint16_t *)cmd->data) == ZYD_CR_INTERRUPT)
1866 return; /* HMAC interrupt */ 1866 return; /* HMAC interrupt */
1867 1867
1868 usbd_get_xfer_status(xfer, NULL, NULL, &datalen, NULL); 1868 usbd_get_xfer_status(xfer, NULL, NULL, &datalen, NULL);
1869 datalen -= sizeof(cmd->code); 1869 datalen -= sizeof(cmd->code);
1870 datalen -= 2; /* XXX: padding? */ 1870 datalen -= 2; /* XXX: padding? */
1871 1871
1872 mutex_enter(&sc->sc_lock); 1872 mutex_enter(&sc->sc_lock);
1873 SIMPLEQ_FOREACH(rqp, &sc->sc_rqh, rq) { 1873 SIMPLEQ_FOREACH(rqp, &sc->sc_rqh, rq) {
@@ -1903,60 +1903,60 @@ zyd_rx_data(struct zyd_softc *sc, const  @@ -1903,60 +1903,60 @@ zyd_rx_data(struct zyd_softc *sc, const
1903{ 1903{
1904 struct ieee80211com *ic = &sc->sc_ic; 1904 struct ieee80211com *ic = &sc->sc_ic;
1905 struct ifnet *ifp = &sc->sc_if; 1905 struct ifnet *ifp = &sc->sc_if;
1906 struct ieee80211_node *ni; 1906 struct ieee80211_node *ni;
1907 struct ieee80211_frame *wh; 1907 struct ieee80211_frame *wh;
1908 const struct zyd_plcphdr *plcp; 1908 const struct zyd_plcphdr *plcp;
1909 const struct zyd_rx_stat *stat; 1909 const struct zyd_rx_stat *stat;
1910 struct mbuf *m; 1910 struct mbuf *m;
1911 int rlen, s; 1911 int rlen, s;
1912 1912
1913 if (len < ZYD_MIN_FRAGSZ) { 1913 if (len < ZYD_MIN_FRAGSZ) {
1914 printf("%s: frame too short (length=%d)\n", 1914 printf("%s: frame too short (length=%d)\n",
1915 device_xname(sc->sc_dev), len); 1915 device_xname(sc->sc_dev), len);
1916 ifp->if_ierrors++; 1916 if_statinc(ifp, if_ierrors);
1917 return; 1917 return;
1918 } 1918 }
1919 1919
1920 plcp = (const struct zyd_plcphdr *)buf; 1920 plcp = (const struct zyd_plcphdr *)buf;
1921 stat = (const struct zyd_rx_stat *) 1921 stat = (const struct zyd_rx_stat *)
1922 (buf + len - sizeof(struct zyd_rx_stat)); 1922 (buf + len - sizeof(struct zyd_rx_stat));
1923 1923
1924 if (stat->flags & ZYD_RX_ERROR) { 1924 if (stat->flags & ZYD_RX_ERROR) {
1925 DPRINTF(("%s: RX status indicated error (%x)\n", 1925 DPRINTF(("%s: RX status indicated error (%x)\n",
1926 device_xname(sc->sc_dev), stat->flags)); 1926 device_xname(sc->sc_dev), stat->flags));
1927 ifp->if_ierrors++; 1927 if_statinc(ifp, if_ierrors);
1928 return; 1928 return;
1929 } 1929 }
1930 1930
1931 /* compute actual frame length */ 1931 /* compute actual frame length */
1932 rlen = len - sizeof(struct zyd_plcphdr) - 1932 rlen = len - sizeof(struct zyd_plcphdr) -
1933 sizeof(struct zyd_rx_stat) - IEEE80211_CRC_LEN; 1933 sizeof(struct zyd_rx_stat) - IEEE80211_CRC_LEN;
1934 1934
1935 /* allocate a mbuf to store the frame */ 1935 /* allocate a mbuf to store the frame */
1936 MGETHDR(m, M_DONTWAIT, MT_DATA); 1936 MGETHDR(m, M_DONTWAIT, MT_DATA);
1937 if (m == NULL) { 1937 if (m == NULL) {
1938 printf("%s: could not allocate rx mbuf\n", 1938 printf("%s: could not allocate rx mbuf\n",
1939 device_xname(sc->sc_dev)); 1939 device_xname(sc->sc_dev));
1940 ifp->if_ierrors++; 1940 if_statinc(ifp, if_ierrors);
1941 return; 1941 return;
1942 } 1942 }
1943 if (rlen > MHLEN) { 1943 if (rlen > MHLEN) {
1944 MCLGET(m, M_DONTWAIT); 1944 MCLGET(m, M_DONTWAIT);
1945 if (!(m->m_flags & M_EXT)) { 1945 if (!(m->m_flags & M_EXT)) {
1946 printf("%s: could not allocate rx mbuf cluster\n", 1946 printf("%s: could not allocate rx mbuf cluster\n",
1947 device_xname(sc->sc_dev)); 1947 device_xname(sc->sc_dev));
1948 m_freem(m); 1948 m_freem(m);
1949 ifp->if_ierrors++; 1949 if_statinc(ifp, if_ierrors);
1950 return; 1950 return;
1951 } 1951 }
1952 } 1952 }
1953 m_set_rcvif(m, ifp); 1953 m_set_rcvif(m, ifp);
1954 m->m_pkthdr.len = m->m_len = rlen; 1954 m->m_pkthdr.len = m->m_len = rlen;
1955 memcpy(mtod(m, uint8_t *), (const uint8_t *)(plcp + 1), rlen); 1955 memcpy(mtod(m, uint8_t *), (const uint8_t *)(plcp + 1), rlen);
1956 1956
1957 s = splnet(); 1957 s = splnet();
1958 1958
1959 if (sc->sc_drvbpf != NULL) { 1959 if (sc->sc_drvbpf != NULL) {
1960 struct zyd_rx_radiotap_header *tap = &sc->sc_rxtap; 1960 struct zyd_rx_radiotap_header *tap = &sc->sc_rxtap;
1961 static const uint8_t rates[] = { 1961 static const uint8_t rates[] = {
1962 /* reverse function of zyd_plcp_signal() */ 1962 /* reverse function of zyd_plcp_signal() */
@@ -1996,27 +1996,27 @@ zyd_rxeof(struct usbd_xfer *xfer, void * @@ -1996,27 +1996,27 @@ zyd_rxeof(struct usbd_xfer *xfer, void *
1996 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 1996 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
1997 return; 1997 return;
1998 1998
1999 if (status == USBD_STALLED) 1999 if (status == USBD_STALLED)
2000 usbd_clear_endpoint_stall(sc->zyd_ep[ZYD_ENDPT_BIN]); 2000 usbd_clear_endpoint_stall(sc->zyd_ep[ZYD_ENDPT_BIN]);
2001 2001
2002 goto skip; 2002 goto skip;
2003 } 2003 }
2004 usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL); 2004 usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
2005 2005
2006 if (len < ZYD_MIN_RXBUFSZ) { 2006 if (len < ZYD_MIN_RXBUFSZ) {
2007 printf("%s: xfer too short (length=%d)\n", 2007 printf("%s: xfer too short (length=%d)\n",
2008 device_xname(sc->sc_dev), len); 2008 device_xname(sc->sc_dev), len);
2009 ifp->if_ierrors++; 2009 if_statinc(ifp, if_ierrors);
2010 goto skip; 2010 goto skip;
2011 } 2011 }
2012 2012
2013 desc = (const struct zyd_rx_desc *) 2013 desc = (const struct zyd_rx_desc *)
2014 (data->buf + len - sizeof(struct zyd_rx_desc)); 2014 (data->buf + len - sizeof(struct zyd_rx_desc));
2015 2015
2016 if (UGETW(desc->tag) == ZYD_TAG_MULTIFRAME) { 2016 if (UGETW(desc->tag) == ZYD_TAG_MULTIFRAME) {
2017 const uint8_t *p = data->buf, *end = p + len; 2017 const uint8_t *p = data->buf, *end = p + len;
2018 int i; 2018 int i;
2019 2019
2020 DPRINTFN(3, ("received multi-frame transfer\n")); 2020 DPRINTFN(3, ("received multi-frame transfer\n"));
2021 2021
2022 for (i = 0; i < ZYD_MAX_RXFRAMECNT; i++) { 2022 for (i = 0; i < ZYD_MAX_RXFRAMECNT; i++) {
@@ -2135,67 +2135,67 @@ zyd_tx_mgt(struct zyd_softc *sc, struct  @@ -2135,67 +2135,67 @@ zyd_tx_mgt(struct zyd_softc *sc, struct
2135 2135
2136 m_copydata(m0, 0, m0->m_pkthdr.len, 2136 m_copydata(m0, 0, m0->m_pkthdr.len,
2137 data->buf + sizeof(struct zyd_tx_desc)); 2137 data->buf + sizeof(struct zyd_tx_desc));
2138 2138
2139 DPRINTFN(10, ("%s: sending mgt frame len=%zu rate=%u xferlen=%u\n", 2139 DPRINTFN(10, ("%s: sending mgt frame len=%zu rate=%u xferlen=%u\n",
2140 device_xname(sc->sc_dev), (size_t)m0->m_pkthdr.len, rate, xferlen)); 2140 device_xname(sc->sc_dev), (size_t)m0->m_pkthdr.len, rate, xferlen));
2141 2141
2142 m_freem(m0); /* mbuf no longer needed */ 2142 m_freem(m0); /* mbuf no longer needed */
2143 2143
2144 usbd_setup_xfer(data->xfer, data, data->buf, xferlen, 2144 usbd_setup_xfer(data->xfer, data, data->buf, xferlen,
2145 USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof); 2145 USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof);
2146 error = usbd_transfer(data->xfer); 2146 error = usbd_transfer(data->xfer);
2147 if (error != USBD_IN_PROGRESS && error != 0) { 2147 if (error != USBD_IN_PROGRESS && error != 0) {
2148 ifp->if_oerrors++; 2148 if_statinc(ifp, if_oerrors);
2149 return EIO; 2149 return EIO;
2150 } 2150 }
2151 sc->tx_queued++; 2151 sc->tx_queued++;
2152 2152
2153 return 0; 2153 return 0;
2154} 2154}
2155 2155
2156Static void 2156Static void
2157zyd_txeof(struct usbd_xfer *xfer, void * priv, usbd_status status) 2157zyd_txeof(struct usbd_xfer *xfer, void * priv, usbd_status status)
2158{ 2158{
2159 struct zyd_tx_data *data = priv; 2159 struct zyd_tx_data *data = priv;
2160 struct zyd_softc *sc = data->sc; 2160 struct zyd_softc *sc = data->sc;
2161 struct ifnet *ifp = &sc->sc_if; 2161 struct ifnet *ifp = &sc->sc_if;
2162 int s; 2162 int s;
2163 2163
2164 if (status != USBD_NORMAL_COMPLETION) { 2164 if (status != USBD_NORMAL_COMPLETION) {
2165 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) 2165 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
2166 return; 2166 return;
2167 2167
2168 printf("%s: could not transmit buffer: %s\n", 2168 printf("%s: could not transmit buffer: %s\n",
2169 device_xname(sc->sc_dev), usbd_errstr(status)); 2169 device_xname(sc->sc_dev), usbd_errstr(status));
2170 2170
2171 if (status == USBD_STALLED) { 2171 if (status == USBD_STALLED) {
2172 usbd_clear_endpoint_stall_async( 2172 usbd_clear_endpoint_stall_async(
2173 sc->zyd_ep[ZYD_ENDPT_BOUT]); 2173 sc->zyd_ep[ZYD_ENDPT_BOUT]);
2174 } 2174 }
2175 ifp->if_oerrors++; 2175 if_statinc(ifp, if_oerrors);
2176 return; 2176 return;
2177 } 2177 }
2178 2178
2179 s = splnet(); 2179 s = splnet();
2180 2180
2181 /* update rate control statistics */ 2181 /* update rate control statistics */
2182 ((struct zyd_node *)data->ni)->amn.amn_txcnt++; 2182 ((struct zyd_node *)data->ni)->amn.amn_txcnt++;
2183 2183
2184 ieee80211_free_node(data->ni); 2184 ieee80211_free_node(data->ni);
2185 data->ni = NULL; 2185 data->ni = NULL;
2186 2186
2187 sc->tx_queued--; 2187 sc->tx_queued--;
2188 ifp->if_opackets++; 2188 if_statinc(ifp, if_opackets);
2189 2189
2190 sc->tx_timer = 0; 2190 sc->tx_timer = 0;
2191 ifp->if_flags &= ~IFF_OACTIVE; 2191 ifp->if_flags &= ~IFF_OACTIVE;
2192 zyd_start(ifp); 2192 zyd_start(ifp);
2193 2193
2194 splx(s); 2194 splx(s);
2195} 2195}
2196 2196
2197Static int 2197Static int
2198zyd_tx_data(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni) 2198zyd_tx_data(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
2199{ 2199{
2200 struct ieee80211com *ic = &sc->sc_ic; 2200 struct ieee80211com *ic = &sc->sc_ic;
2201 struct ifnet *ifp = &sc->sc_if; 2201 struct ifnet *ifp = &sc->sc_if;
@@ -2292,27 +2292,27 @@ zyd_tx_data(struct zyd_softc *sc, struct @@ -2292,27 +2292,27 @@ zyd_tx_data(struct zyd_softc *sc, struct
2292 2292
2293 m_copydata(m0, 0, m0->m_pkthdr.len, 2293 m_copydata(m0, 0, m0->m_pkthdr.len,
2294 data->buf + sizeof(struct zyd_tx_desc)); 2294 data->buf + sizeof(struct zyd_tx_desc));
2295 2295
2296 DPRINTFN(10, ("%s: sending data frame len=%zu rate=%u xferlen=%u\n", 2296 DPRINTFN(10, ("%s: sending data frame len=%zu rate=%u xferlen=%u\n",
2297 device_xname(sc->sc_dev), (size_t)m0->m_pkthdr.len, rate, xferlen)); 2297 device_xname(sc->sc_dev), (size_t)m0->m_pkthdr.len, rate, xferlen));
2298 2298
2299 m_freem(m0); /* mbuf no longer needed */ 2299 m_freem(m0); /* mbuf no longer needed */
2300 2300
2301 usbd_setup_xfer(data->xfer, data, data->buf, xferlen, 2301 usbd_setup_xfer(data->xfer, data, data->buf, xferlen,
2302 USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof); 2302 USBD_FORCE_SHORT_XFER, ZYD_TX_TIMEOUT, zyd_txeof);
2303 error = usbd_transfer(data->xfer); 2303 error = usbd_transfer(data->xfer);
2304 if (error != USBD_IN_PROGRESS && error != 0) { 2304 if (error != USBD_IN_PROGRESS && error != 0) {
2305 ifp->if_oerrors++; 2305 if_statinc(ifp, if_oerrors);
2306 return EIO; 2306 return EIO;
2307 } 2307 }
2308 sc->tx_queued++; 2308 sc->tx_queued++;
2309 2309
2310 return 0; 2310 return 0;
2311} 2311}
2312 2312
2313Static void 2313Static void
2314zyd_start(struct ifnet *ifp) 2314zyd_start(struct ifnet *ifp)
2315{ 2315{
2316 struct zyd_softc *sc = ifp->if_softc; 2316 struct zyd_softc *sc = ifp->if_softc;
2317 struct ieee80211com *ic = &sc->sc_ic; 2317 struct ieee80211com *ic = &sc->sc_ic;
2318 struct ether_header *eh; 2318 struct ether_header *eh;
@@ -2348,55 +2348,55 @@ zyd_start(struct ifnet *ifp) @@ -2348,55 +2348,55 @@ zyd_start(struct ifnet *ifp)
2348 if (m0->m_len < sizeof(struct ether_header) && 2348 if (m0->m_len < sizeof(struct ether_header) &&
2349 !(m0 = m_pullup(m0, sizeof(struct ether_header)))) 2349 !(m0 = m_pullup(m0, sizeof(struct ether_header))))
2350 continue; 2350 continue;
2351 2351
2352 eh = mtod(m0, struct ether_header *); 2352 eh = mtod(m0, struct ether_header *);
2353 ni = ieee80211_find_txnode(ic, eh->ether_dhost); 2353 ni = ieee80211_find_txnode(ic, eh->ether_dhost);
2354 if (ni == NULL) { 2354 if (ni == NULL) {
2355 m_freem(m0); 2355 m_freem(m0);
2356 continue; 2356 continue;
2357 } 2357 }
2358 bpf_mtap(ifp, m0, BPF_D_OUT); 2358 bpf_mtap(ifp, m0, BPF_D_OUT);
2359 if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) { 2359 if ((m0 = ieee80211_encap(ic, m0, ni)) == NULL) {
2360 ieee80211_free_node(ni); 2360 ieee80211_free_node(ni);
2361 ifp->if_oerrors++; 2361 if_statinc(ifp, if_oerrors);
2362 continue; 2362 continue;
2363 } 2363 }
2364 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT); 2364 bpf_mtap3(ic->ic_rawbpf, m0, BPF_D_OUT);
2365 if (zyd_tx_data(sc, m0, ni) != 0) { 2365 if (zyd_tx_data(sc, m0, ni) != 0) {
2366 ieee80211_free_node(ni); 2366 ieee80211_free_node(ni);
2367 ifp->if_oerrors++; 2367 if_statinc(ifp, if_oerrors);
2368 break; 2368 break;
2369 } 2369 }
2370 } 2370 }
2371 2371
2372 sc->tx_timer = 5; 2372 sc->tx_timer = 5;
2373 ifp->if_timer = 1; 2373 ifp->if_timer = 1;
2374 } 2374 }
2375} 2375}
2376 2376
2377Static void 2377Static void
2378zyd_watchdog(struct ifnet *ifp) 2378zyd_watchdog(struct ifnet *ifp)
2379{ 2379{
2380 struct zyd_softc *sc = ifp->if_softc; 2380 struct zyd_softc *sc = ifp->if_softc;
2381 struct ieee80211com *ic = &sc->sc_ic; 2381 struct ieee80211com *ic = &sc->sc_ic;
2382 2382
2383 ifp->if_timer = 0; 2383 ifp->if_timer = 0;
2384 2384
2385 if (sc->tx_timer > 0) { 2385 if (sc->tx_timer > 0) {
2386 if (--sc->tx_timer == 0) { 2386 if (--sc->tx_timer == 0) {
2387 printf("%s: device timeout\n", device_xname(sc->sc_dev)); 2387 printf("%s: device timeout\n", device_xname(sc->sc_dev));
2388 /* zyd_init(ifp); XXX needs a process context ? */ 2388 /* zyd_init(ifp); XXX needs a process context ? */
2389 ifp->if_oerrors++; 2389 if_statinc(ifp, if_oerrors);
2390 return; 2390 return;
2391 } 2391 }
2392 ifp->if_timer = 1; 2392 ifp->if_timer = 1;
2393 } 2393 }
2394 2394
2395 ieee80211_watchdog(ic); 2395 ieee80211_watchdog(ic);
2396} 2396}
2397 2397
2398Static int 2398Static int
2399zyd_ioctl(struct ifnet *ifp, u_long cmd, void *data) 2399zyd_ioctl(struct ifnet *ifp, u_long cmd, void *data)
2400{ 2400{
2401 struct zyd_softc *sc = ifp->if_softc; 2401 struct zyd_softc *sc = ifp->if_softc;
2402 struct ieee80211com *ic = &sc->sc_ic; 2402 struct ieee80211com *ic = &sc->sc_ic;

cvs diff -r1.31 -r1.32 src/sys/dev/usb/uhso.c (expand / switch to unified diff)

--- src/sys/dev/usb/uhso.c 2019/12/01 08:27:54 1.31
+++ src/sys/dev/usb/uhso.c 2020/01/29 06:39:07 1.32
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uhso.c,v 1.31 2019/12/01 08:27:54 maxv Exp $ */ 1/* $NetBSD: uhso.c,v 1.32 2020/01/29 06:39:07 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2009 Iain Hibbert 4 * Copyright (c) 2009 Iain Hibbert
5 * Copyright (c) 2008 Fredrik Lindberg 5 * Copyright (c) 2008 Fredrik Lindberg
6 * All rights reserved. 6 * 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
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 */ 27 */
28 28
29/* 29/*
30 * This driver originated as the hso module for FreeBSD written by 30 * This driver originated as the hso module for FreeBSD written by
31 * Fredrik Lindberg[1]. It has been rewritten almost completely for 31 * Fredrik Lindberg[1]. It has been rewritten almost completely for
32 * NetBSD, and to support more devices with information extracted from 32 * NetBSD, and to support more devices with information extracted from
33 * the Linux hso driver provided by Option N.V.[2] 33 * the Linux hso driver provided by Option N.V.[2]
34 * 34 *
35 * [1] http://www.shapeshifter.se/code/hso 35 * [1] http://www.shapeshifter.se/code/hso
36 * [2] http://www.pharscape.org/hso.htm 36 * [2] http://www.pharscape.org/hso.htm
37 */ 37 */
38 38
39#include <sys/cdefs.h> 39#include <sys/cdefs.h>
40__KERNEL_RCSID(0, "$NetBSD: uhso.c,v 1.31 2019/12/01 08:27:54 maxv Exp $"); 40__KERNEL_RCSID(0, "$NetBSD: uhso.c,v 1.32 2020/01/29 06:39:07 thorpej Exp $");
41 41
42#ifdef _KERNEL_OPT 42#ifdef _KERNEL_OPT
43#include "opt_inet.h" 43#include "opt_inet.h"
44#include "opt_usb.h" 44#include "opt_usb.h"
45#endif 45#endif
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/conf.h> 48#include <sys/conf.h>
49#include <sys/fcntl.h> 49#include <sys/fcntl.h>
50#include <sys/kauth.h> 50#include <sys/kauth.h>
51#include <sys/kernel.h> 51#include <sys/kernel.h>
52#include <sys/kmem.h> 52#include <sys/kmem.h>
53#include <sys/mbuf.h> 53#include <sys/mbuf.h>
@@ -2014,35 +2014,35 @@ uhso_ifnet_write_cb(struct usbd_xfer *xf @@ -2014,35 +2014,35 @@ uhso_ifnet_write_cb(struct usbd_xfer *xf
2014 usb_detach_wakeupold(sc->sc_dev); 2014 usb_detach_wakeupold(sc->sc_dev);
2015 2015
2016 if (!ISSET(ifp->if_flags, IFF_RUNNING)) 2016 if (!ISSET(ifp->if_flags, IFF_RUNNING))
2017 return; 2017 return;
2018 2018
2019 if (status != USBD_NORMAL_COMPLETION) { 2019 if (status != USBD_NORMAL_COMPLETION) {
2020 DPRINTF(0, "non-normal status %s\n", usbd_errstr(status)); 2020 DPRINTF(0, "non-normal status %s\n", usbd_errstr(status));
2021 2021
2022 if (status == USBD_STALLED && hp->hp_wpipe != NULL) 2022 if (status == USBD_STALLED && hp->hp_wpipe != NULL)
2023 usbd_clear_endpoint_stall_async(hp->hp_wpipe); 2023 usbd_clear_endpoint_stall_async(hp->hp_wpipe);
2024 else 2024 else
2025 return; 2025 return;
2026 2026
2027 ifp->if_oerrors++; 2027 if_statinc(ifp, if_oerrors);
2028 } else { 2028 } else {
2029 usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL); 2029 usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL);
2030 DPRINTF(5, "wrote %d bytes (of %zd)\n", cc, hp->hp_wlen); 2030 DPRINTF(5, "wrote %d bytes (of %zd)\n", cc, hp->hp_wlen);
2031 2031
2032 if (cc != hp->hp_wlen) 2032 if (cc != hp->hp_wlen)
2033 DPRINTF(0, "cc=%u, wlen=%zd\n", cc, hp->hp_wlen); 2033 DPRINTF(0, "cc=%u, wlen=%zd\n", cc, hp->hp_wlen);
2034 2034
2035 ifp->if_opackets++; 2035 if_statinc(ifp, if_opackets);
2036 } 2036 }
2037 2037
2038 s = splnet(); 2038 s = splnet();
2039 CLR(ifp->if_flags, IFF_OACTIVE); 2039 CLR(ifp->if_flags, IFF_OACTIVE);
2040 ifp->if_start(ifp); 2040 ifp->if_start(ifp);
2041 splx(s); 2041 splx(s);
2042} 2042}
2043 2043
2044Static void 2044Static void
2045uhso_ifnet_read_cb(struct usbd_xfer *xfer, void * p, 2045uhso_ifnet_read_cb(struct usbd_xfer *xfer, void * p,
2046 usbd_status status) 2046 usbd_status status)
2047{ 2047{
2048 struct uhso_port *hp = p; 2048 struct uhso_port *hp = p;
@@ -2055,27 +2055,27 @@ uhso_ifnet_read_cb(struct usbd_xfer *xfe @@ -2055,27 +2055,27 @@ uhso_ifnet_read_cb(struct usbd_xfer *xfe
2055 usb_detach_wakeupold(sc->sc_dev); 2055 usb_detach_wakeupold(sc->sc_dev);
2056 2056
2057 if (!ISSET(ifp->if_flags, IFF_RUNNING)) 2057 if (!ISSET(ifp->if_flags, IFF_RUNNING))
2058 return; 2058 return;
2059 2059
2060 if (status != USBD_NORMAL_COMPLETION) { 2060 if (status != USBD_NORMAL_COMPLETION) {
2061 DPRINTF(0, "non-normal status: %s\n", usbd_errstr(status)); 2061 DPRINTF(0, "non-normal status: %s\n", usbd_errstr(status));
2062 2062
2063 if (status == USBD_STALLED && hp->hp_rpipe != NULL) 2063 if (status == USBD_STALLED && hp->hp_rpipe != NULL)
2064 usbd_clear_endpoint_stall_async(hp->hp_rpipe); 2064 usbd_clear_endpoint_stall_async(hp->hp_rpipe);
2065 else 2065 else
2066 return; 2066 return;
2067 2067
2068 ifp->if_ierrors++; 2068 if_statinc(ifp, if_ierrors);
2069 hp->hp_rlen = 0; 2069 hp->hp_rlen = 0;
2070 } else { 2070 } else {
2071 usbd_get_xfer_status(xfer, NULL, (void **)&cp, &cc, NULL); 2071 usbd_get_xfer_status(xfer, NULL, (void **)&cp, &cc, NULL);
2072 2072
2073 hp->hp_rlen = cc; 2073 hp->hp_rlen = cc;
2074 DPRINTF(5, "read %d bytes\n", cc); 2074 DPRINTF(5, "read %d bytes\n", cc);
2075 2075
2076 uhso_ifnet_input(ifp, &hp->hp_mbuf, cp, cc); 2076 uhso_ifnet_input(ifp, &hp->hp_mbuf, cp, cc);
2077 } 2077 }
2078 2078
2079 (*hp->hp_read)(hp); 2079 (*hp->hp_read)(hp);
2080} 2080}
2081 2081
@@ -2087,57 +2087,57 @@ uhso_ifnet_input(struct ifnet *ifp, stru @@ -2087,57 +2087,57 @@ uhso_ifnet_input(struct ifnet *ifp, stru
2087 int s; 2087 int s;
2088 2088
2089 /* 2089 /*
2090 * Several IP packets might be in the same buffer, we need to 2090 * Several IP packets might be in the same buffer, we need to
2091 * separate them before handing it to the ip-stack. We might 2091 * separate them before handing it to the ip-stack. We might
2092 * also receive partial packets which we need to defer until 2092 * also receive partial packets which we need to defer until
2093 * we get more data. 2093 * we get more data.
2094 */ 2094 */
2095 while (cc > 0) { 2095 while (cc > 0) {
2096 if (*mb == NULL) { 2096 if (*mb == NULL) {
2097 MGETHDR(m, M_DONTWAIT, MT_DATA); 2097 MGETHDR(m, M_DONTWAIT, MT_DATA);
2098 if (m == NULL) { 2098 if (m == NULL) {
2099 aprint_error_ifnet(ifp, "no mbufs\n"); 2099 aprint_error_ifnet(ifp, "no mbufs\n");
2100 ifp->if_ierrors++; 2100 if_statinc(ifp, if_ierrors);
2101 break; 2101 break;
2102 } 2102 }
2103 2103
2104 MCLGET(m, M_DONTWAIT); 2104 MCLGET(m, M_DONTWAIT);
2105 if (!ISSET(m->m_flags, M_EXT)) { 2105 if (!ISSET(m->m_flags, M_EXT)) {
2106 aprint_error_ifnet(ifp, "no mbuf clusters\n"); 2106 aprint_error_ifnet(ifp, "no mbuf clusters\n");
2107 ifp->if_ierrors++; 2107 if_statinc(ifp, if_ierrors);
2108 m_freem(m); 2108 m_freem(m);
2109 break; 2109 break;
2110 } 2110 }
2111 2111
2112 got = 0; 2112 got = 0;
2113 } else { 2113 } else {
2114 m = *mb; 2114 m = *mb;
2115 *mb = NULL; 2115 *mb = NULL;
2116 got = m->m_pkthdr.len; 2116 got = m->m_pkthdr.len;
2117 } 2117 }
2118 2118
2119 /* make sure that the incoming packet is ok */ 2119 /* make sure that the incoming packet is ok */
2120 if (got == 0) 2120 if (got == 0)
2121 mtod(m, uint8_t *)[0] = cp[0]; 2121 mtod(m, uint8_t *)[0] = cp[0];
2122 2122
2123 want = mtod(m, struct ip *)->ip_hl << 2; 2123 want = mtod(m, struct ip *)->ip_hl << 2;
2124 if (mtod(m, struct ip *)->ip_v != 4 2124 if (mtod(m, struct ip *)->ip_v != 4
2125 || want != sizeof(struct ip)) { 2125 || want != sizeof(struct ip)) {
2126 aprint_error_ifnet(ifp, 2126 aprint_error_ifnet(ifp,
2127 "bad IP header (v=%d, hl=%zd)\n", 2127 "bad IP header (v=%d, hl=%zd)\n",
2128 mtod(m, struct ip *)->ip_v, want); 2128 mtod(m, struct ip *)->ip_v, want);
2129 2129
2130 ifp->if_ierrors++; 2130 if_statinc(ifp, if_ierrors);
2131 m_freem(m); 2131 m_freem(m);
2132 break; 2132 break;
2133 } 2133 }
2134 2134
2135 /* ensure we have the IP header.. */ 2135 /* ensure we have the IP header.. */
2136 if (got < want) { 2136 if (got < want) {
2137 len = MIN(want - got, cc); 2137 len = MIN(want - got, cc);
2138 memcpy(mtod(m, uint8_t *) + got, cp, len); 2138 memcpy(mtod(m, uint8_t *) + got, cp, len);
2139 got += len; 2139 got += len;
2140 cc -= len; 2140 cc -= len;
2141 cp += len; 2141 cp += len;
2142 2142
2143 if (got < want) { 2143 if (got < want) {
@@ -2169,28 +2169,27 @@ uhso_ifnet_input(struct ifnet *ifp, stru @@ -2169,28 +2169,27 @@ uhso_ifnet_input(struct ifnet *ifp, stru
2169 } 2169 }
2170 } 2170 }
2171 2171
2172 m_set_rcvif(m, ifp); 2172 m_set_rcvif(m, ifp);
2173 m->m_pkthdr.len = m->m_len = got; 2173 m->m_pkthdr.len = m->m_len = got;
2174 2174
2175 s = splnet(); 2175 s = splnet();
2176 2176
2177 bpf_mtap(ifp, m, BPF_D_IN); 2177 bpf_mtap(ifp, m, BPF_D_IN);
2178 2178
2179 if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) { 2179 if (__predict_false(!pktq_enqueue(ip_pktq, m, 0))) {
2180 m_freem(m); 2180 m_freem(m);
2181 } else { 2181 } else {
2182 ifp->if_ipackets++; 2182 if_statadd2(ifp, if_ipackets, 1, if_ibytes, got);
2183 ifp->if_ibytes += got; 
2184 } 2183 }
2185 splx(s); 2184 splx(s);
2186 } 2185 }
2187} 2186}
2188 2187
2189Static int 2188Static int
2190uhso_ifnet_ioctl(struct ifnet *ifp, u_long cmd, void *data) 2189uhso_ifnet_ioctl(struct ifnet *ifp, u_long cmd, void *data)
2191{ 2190{
2192 struct uhso_port *hp = ifp->if_softc; 2191 struct uhso_port *hp = ifp->if_softc;
2193 int error, s; 2192 int error, s;
2194 2193
2195 s = splnet(); 2194 s = splnet();
2196 2195
@@ -2329,27 +2328,27 @@ uhso_ifnet_start(struct ifnet *ifp) @@ -2329,27 +2328,27 @@ uhso_ifnet_start(struct ifnet *ifp)
2329 aprint_error_ifnet(ifp, 2328 aprint_error_ifnet(ifp,
2330 "packet too long (%zd > %zd), truncating\n", 2329 "packet too long (%zd > %zd), truncating\n",
2331 hp->hp_wlen, hp->hp_wsize); 2330 hp->hp_wlen, hp->hp_wsize);
2332 2331
2333 hp->hp_wlen = hp->hp_wsize; 2332 hp->hp_wlen = hp->hp_wsize;
2334 } 2333 }
2335 2334
2336 bpf_mtap(ifp, m, BPF_D_OUT); 2335 bpf_mtap(ifp, m, BPF_D_OUT);
2337 2336
2338 m_copydata(m, 0, hp->hp_wlen, hp->hp_wbuf); 2337 m_copydata(m, 0, hp->hp_wlen, hp->hp_wbuf);
2339 m_freem(m); 2338 m_freem(m);
2340 2339
2341 if ((*hp->hp_write)(hp) != 0) { 2340 if ((*hp->hp_write)(hp) != 0) {
2342 ifp->if_oerrors++; 2341 if_statinc(ifp, if_oerrors);
2343 CLR(ifp->if_flags, IFF_OACTIVE); 2342 CLR(ifp->if_flags, IFF_OACTIVE);
2344 } 2343 }
2345} 2344}
2346 2345
2347Static int 2346Static int
2348uhso_ifnet_output(struct ifnet *ifp, struct mbuf *m, 2347uhso_ifnet_output(struct ifnet *ifp, struct mbuf *m,
2349 const struct sockaddr *dst, const struct rtentry *rt0) 2348 const struct sockaddr *dst, const struct rtentry *rt0)
2350{ 2349{
2351 int error; 2350 int error;
2352 2351
2353 if (!ISSET(ifp->if_flags, IFF_RUNNING)) 2352 if (!ISSET(ifp->if_flags, IFF_RUNNING))
2354 return EIO; 2353 return EIO;
2355 2354

cvs diff -r1.33 -r1.34 src/sys/dev/usb/usbnet.c (expand / switch to unified diff)

--- src/sys/dev/usb/usbnet.c 2019/12/14 15:40:43 1.33
+++ src/sys/dev/usb/usbnet.c 2020/01/29 06:39:07 1.34
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: usbnet.c,v 1.33 2019/12/14 15:40:43 maya Exp $ */ 1/* $NetBSD: usbnet.c,v 1.34 2020/01/29 06:39:07 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2019 Matthew R. Green 4 * Copyright (c) 2019 Matthew R. Green
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 */ 29 */
30 30
31/* 31/*
32 * Common code shared between USB network drivers. 32 * Common code shared between USB network drivers.
33 */ 33 */
34 34
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.33 2019/12/14 15:40:43 maya Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.34 2020/01/29 06:39:07 thorpej Exp $");
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/kernel.h> 39#include <sys/kernel.h>
40#include <sys/kmem.h> 40#include <sys/kmem.h>
41#include <sys/module.h> 41#include <sys/module.h>
42#include <sys/atomic.h> 42#include <sys/atomic.h>
43 43
44#include <dev/usb/usbnet.h> 44#include <dev/usb/usbnet.h>
45#include <dev/usb/usbhist.h> 45#include <dev/usb/usbhist.h>
46 46
47struct usbnet_cdata { 47struct usbnet_cdata {
48 struct usbnet_chain *uncd_tx_chain; 48 struct usbnet_chain *uncd_tx_chain;
49 struct usbnet_chain *uncd_rx_chain; 49 struct usbnet_chain *uncd_rx_chain;
@@ -261,27 +261,27 @@ usbnet_enqueue(struct usbnet * const un, @@ -261,27 +261,27 @@ usbnet_enqueue(struct usbnet * const un,
261 USBNETHIST_FUNC(); 261 USBNETHIST_FUNC();
262 struct ifnet * const ifp = usbnet_ifp(un); 262 struct ifnet * const ifp = usbnet_ifp(un);
263 struct usbnet_private * const unp __unused = un->un_pri; 263 struct usbnet_private * const unp __unused = un->un_pri;
264 struct mbuf *m; 264 struct mbuf *m;
265 265
266 USBNETHIST_CALLARGSN(5, "%d: enter: len=%zu csf %x mbf %x", 266 USBNETHIST_CALLARGSN(5, "%d: enter: len=%zu csf %x mbf %x",
267 unp->unp_number, buflen, csum_flags, mbuf_flags); 267 unp->unp_number, buflen, csum_flags, mbuf_flags);
268 268
269 usbnet_isowned_rx(un); 269 usbnet_isowned_rx(un);
270 270
271 m = usbnet_newbuf(buflen); 271 m = usbnet_newbuf(buflen);
272 if (m == NULL) { 272 if (m == NULL) {
273 DPRINTF("%d: no memory", unp->unp_number, 0, 0, 0); 273 DPRINTF("%d: no memory", unp->unp_number, 0, 0, 0);
274 ifp->if_ierrors++; 274 if_statinc(ifp, if_ierrors);
275 return; 275 return;
276 } 276 }
277 277
278 m_set_rcvif(m, ifp); 278 m_set_rcvif(m, ifp);
279 m->m_pkthdr.csum_flags = csum_flags; 279 m->m_pkthdr.csum_flags = csum_flags;
280 m->m_pkthdr.csum_data = csum_data; 280 m->m_pkthdr.csum_data = csum_data;
281 m->m_flags |= mbuf_flags; 281 m->m_flags |= mbuf_flags;
282 memcpy(mtod(m, uint8_t *), buf, buflen); 282 memcpy(mtod(m, uint8_t *), buf, buflen);
283 283
284 /* push the packet up */ 284 /* push the packet up */
285 if_percpuq_enqueue(ifp->if_percpuq, m); 285 if_percpuq_enqueue(ifp->if_percpuq, m);
286} 286}
287 287
@@ -290,27 +290,27 @@ usbnet_input(struct usbnet * const un, u @@ -290,27 +290,27 @@ usbnet_input(struct usbnet * const un, u
290{ 290{
291 USBNETHIST_FUNC(); 291 USBNETHIST_FUNC();
292 struct ifnet * const ifp = usbnet_ifp(un); 292 struct ifnet * const ifp = usbnet_ifp(un);
293 struct usbnet_private * const unp __unused = un->un_pri; 293 struct usbnet_private * const unp __unused = un->un_pri;
294 struct mbuf *m; 294 struct mbuf *m;
295 295
296 USBNETHIST_CALLARGSN(5, "%d: enter: buf %jx len %ju", 296 USBNETHIST_CALLARGSN(5, "%d: enter: buf %jx len %ju",
297 unp->unp_number, (uintptr_t)buf, buflen, 0); 297 unp->unp_number, (uintptr_t)buf, buflen, 0);
298 298
299 usbnet_isowned_rx(un); 299 usbnet_isowned_rx(un);
300 300
301 m = usbnet_newbuf(buflen); 301 m = usbnet_newbuf(buflen);
302 if (m == NULL) { 302 if (m == NULL) {
303 ifp->if_ierrors++; 303 if_statinc(ifp, if_ierrors);
304 return; 304 return;
305 } 305 }
306 306
307 m_set_rcvif(m, ifp); 307 m_set_rcvif(m, ifp);
308 memcpy(mtod(m, char *), buf, buflen); 308 memcpy(mtod(m, char *), buf, buflen);
309 309
310 /* push the packet up */ 310 /* push the packet up */
311 if_input(ifp, m); 311 if_input(ifp, m);
312} 312}
313 313
314/* 314/*
315 * A frame has been uploaded: pass the resulting mbuf chain up to 315 * A frame has been uploaded: pass the resulting mbuf chain up to
316 * the higher level protocols. 316 * the higher level protocols.
@@ -392,32 +392,32 @@ usbnet_txeof(struct usbd_xfer *xfer, voi @@ -392,32 +392,32 @@ usbnet_txeof(struct usbd_xfer *xfer, voi
392 } 392 }
393 393
394 KASSERT(cd->uncd_tx_cnt > 0); 394 KASSERT(cd->uncd_tx_cnt > 0);
395 cd->uncd_tx_cnt--; 395 cd->uncd_tx_cnt--;
396 396
397 unp->unp_timer = 0; 397 unp->unp_timer = 0;
398 398
399 switch (status) { 399 switch (status) {
400 case USBD_NOT_STARTED: 400 case USBD_NOT_STARTED:
401 case USBD_CANCELLED: 401 case USBD_CANCELLED:
402 break; 402 break;
403 403
404 case USBD_NORMAL_COMPLETION: 404 case USBD_NORMAL_COMPLETION:
405 ifp->if_opackets++; 405 if_statinc(ifp, if_opackets);
406 break; 406 break;
407 407
408 default: 408 default:
409 409
410 ifp->if_oerrors++; 410 if_statinc(ifp, if_oerrors);
411 if (usbd_ratecheck(&unp->unp_tx_notice)) 411 if (usbd_ratecheck(&unp->unp_tx_notice))
412 aprint_error_dev(un->un_dev, "usb error on tx: %s\n", 412 aprint_error_dev(un->un_dev, "usb error on tx: %s\n",
413 usbd_errstr(status)); 413 usbd_errstr(status));
414 if (status == USBD_STALLED) 414 if (status == USBD_STALLED)
415 usbd_clear_endpoint_stall_async(unp->unp_ep[USBNET_ENDPT_TX]); 415 usbd_clear_endpoint_stall_async(unp->unp_ep[USBNET_ENDPT_TX]);
416 break; 416 break;
417 } 417 }
418 418
419 mutex_exit(&unp->unp_txlock); 419 mutex_exit(&unp->unp_txlock);
420 420
421 if (status == USBD_NORMAL_COMPLETION && !IFQ_IS_EMPTY(&ifp->if_snd)) 421 if (status == USBD_NORMAL_COMPLETION && !IFQ_IS_EMPTY(&ifp->if_snd))
422 (*ifp->if_start)(ifp); 422 (*ifp->if_start)(ifp);
423} 423}
@@ -490,45 +490,45 @@ usbnet_start_locked(struct ifnet *ifp) @@ -490,45 +490,45 @@ usbnet_start_locked(struct ifnet *ifp)
490 while (cd->uncd_tx_cnt < un->un_tx_list_cnt) { 490 while (cd->uncd_tx_cnt < un->un_tx_list_cnt) {
491 IFQ_POLL(&ifp->if_snd, m); 491 IFQ_POLL(&ifp->if_snd, m);
492 if (m == NULL) { 492 if (m == NULL) {
493 DPRINTF("start called, queue empty", 0, 0, 0, 0); 493 DPRINTF("start called, queue empty", 0, 0, 0, 0);
494 break; 494 break;
495 } 495 }
496 KASSERT(m->m_pkthdr.len <= un->un_tx_bufsz); 496 KASSERT(m->m_pkthdr.len <= un->un_tx_bufsz);
497 497
498 struct usbnet_chain *c = &cd->uncd_tx_chain[idx]; 498 struct usbnet_chain *c = &cd->uncd_tx_chain[idx];
499 499
500 length = uno_tx_prepare(un, m, c); 500 length = uno_tx_prepare(un, m, c);
501 if (length == 0) { 501 if (length == 0) {
502 DPRINTF("uno_tx_prepare gave zero length", 0, 0, 0, 0); 502 DPRINTF("uno_tx_prepare gave zero length", 0, 0, 0, 0);
503 ifp->if_oerrors++; 503 if_statinc(ifp, if_oerrors);
504 break; 504 break;
505 } 505 }
506 506
507 if (__predict_false(c->unc_xfer == NULL)) { 507 if (__predict_false(c->unc_xfer == NULL)) {
508 DPRINTF("unc_xfer is NULL", 0, 0, 0, 0); 508 DPRINTF("unc_xfer is NULL", 0, 0, 0, 0);
509 ifp->if_oerrors++; 509 if_statinc(ifp, if_oerrors);
510 break; 510 break;
511 } 511 }
512 512
513 usbd_setup_xfer(c->unc_xfer, c, c->unc_buf, length, 513 usbd_setup_xfer(c->unc_xfer, c, c->unc_buf, length,
514 un->un_tx_xfer_flags, 10000, usbnet_txeof); 514 un->un_tx_xfer_flags, 10000, usbnet_txeof);
515 515
516 /* Transmit */ 516 /* Transmit */
517 usbd_status err = usbd_transfer(c->unc_xfer); 517 usbd_status err = usbd_transfer(c->unc_xfer);
518 if (err != USBD_IN_PROGRESS) { 518 if (err != USBD_IN_PROGRESS) {
519 DPRINTF("usbd_transfer on %jx for %ju bytes: %d", 519 DPRINTF("usbd_transfer on %jx for %ju bytes: %d",
520 (uintptr_t)c->unc_buf, length, err, 0); 520 (uintptr_t)c->unc_buf, length, err, 0);
521 ifp->if_oerrors++; 521 if_statinc(ifp, if_oerrors);
522 break; 522 break;
523 } 523 }
524 done_transmit = true; 524 done_transmit = true;
525 525
526 IFQ_DEQUEUE(&ifp->if_snd, m); 526 IFQ_DEQUEUE(&ifp->if_snd, m);
527 527
528 /* 528 /*
529 * If there's a BPF listener, bounce a copy of this frame 529 * If there's a BPF listener, bounce a copy of this frame
530 * to him. 530 * to him.
531 */ 531 */
532 bpf_mtap(ifp, m, BPF_D_OUT); 532 bpf_mtap(ifp, m, BPF_D_OUT);
533 m_freem(m); 533 m_freem(m);
534 534
@@ -1139,27 +1139,27 @@ usbnet_tick(void *arg) @@ -1139,27 +1139,27 @@ usbnet_tick(void *arg)
1139 usb_add_task(un->un_udev, &unp->unp_ticktask, USB_TASKQ_DRIVER); 1139 usb_add_task(un->un_udev, &unp->unp_ticktask, USB_TASKQ_DRIVER);
1140 } 1140 }
1141} 1141}
1142 1142
1143static void 1143static void
1144usbnet_watchdog(struct ifnet *ifp) 1144usbnet_watchdog(struct ifnet *ifp)
1145{ 1145{
1146 USBNETHIST_FUNC(); USBNETHIST_CALLED(); 1146 USBNETHIST_FUNC(); USBNETHIST_CALLED();
1147 struct usbnet * const un = ifp->if_softc; 1147 struct usbnet * const un = ifp->if_softc;
1148 struct usbnet_private * const unp = un->un_pri; 1148 struct usbnet_private * const unp = un->un_pri;
1149 struct usbnet_cdata * const cd = un_cdata(un); 1149 struct usbnet_cdata * const cd = un_cdata(un);
1150 usbd_status err; 1150 usbd_status err;
1151 1151
1152 ifp->if_oerrors++; 1152 if_statinc(ifp, if_oerrors);
1153 aprint_error_dev(un->un_dev, "watchdog timeout\n"); 1153 aprint_error_dev(un->un_dev, "watchdog timeout\n");
1154 1154
1155 if (cd->uncd_tx_cnt > 0) { 1155 if (cd->uncd_tx_cnt > 0) {
1156 DPRINTF("uncd_tx_cnt=%u non zero, aborting pipe", 0, 0, 0, 0); 1156 DPRINTF("uncd_tx_cnt=%u non zero, aborting pipe", 0, 0, 0, 0);
1157 err = usbd_abort_pipe(unp->unp_ep[USBNET_ENDPT_TX]); 1157 err = usbd_abort_pipe(unp->unp_ep[USBNET_ENDPT_TX]);
1158 if (err) 1158 if (err)
1159 aprint_error_dev(un->un_dev, "pipe abort failed: %s\n", 1159 aprint_error_dev(un->un_dev, "pipe abort failed: %s\n",
1160 usbd_errstr(err)); 1160 usbd_errstr(err));
1161 if (cd->uncd_tx_cnt != 0) 1161 if (cd->uncd_tx_cnt != 0)
1162 DPRINTF("uncd_tx_cnt now %u", cd->uncd_tx_cnt, 0, 0, 0); 1162 DPRINTF("uncd_tx_cnt now %u", cd->uncd_tx_cnt, 0, 0, 0);
1163 } 1163 }
1164 1164
1165 if (!IFQ_IS_EMPTY(&ifp->if_snd)) 1165 if (!IFQ_IS_EMPTY(&ifp->if_snd))