Thu Mar 3 05:55:01 2022 UTC ()
usbnet drivers: Omit needless isdying tests in *_uno_init.

usbnet(9) already checks this immediately before calling *_uno_init.


(riastradh)
diff -r1.186 -r1.187 src/sys/dev/usb/if_aue.c
diff -r1.145 -r1.146 src/sys/dev/usb/if_axe.c
diff -r1.89 -r1.90 src/sys/dev/usb/if_axen.c
diff -r1.74 -r1.75 src/sys/dev/usb/if_cdce.c
diff -r1.102 -r1.103 src/sys/dev/usb/if_cue.c
diff -r1.114 -r1.115 src/sys/dev/usb/if_kue.c
diff -r1.17 -r1.18 src/sys/dev/usb/if_mos.c
diff -r1.77 -r1.78 src/sys/dev/usb/if_mue.c
diff -r1.87 -r1.88 src/sys/dev/usb/if_smsc.c
diff -r1.92 -r1.93 src/sys/dev/usb/if_udav.c
diff -r1.72 -r1.73 src/sys/dev/usb/if_upl.c
diff -r1.52 -r1.53 src/sys/dev/usb/if_ure.c
diff -r1.91 -r1.92 src/sys/dev/usb/if_url.c

cvs diff -r1.186 -r1.187 src/sys/dev/usb/if_aue.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_aue.c 2022/03/03 05:54:37 1.186
+++ src/sys/dev/usb/if_aue.c 2022/03/03 05:55:01 1.187
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_aue.c,v 1.186 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_aue.c,v 1.187 2022/03/03 05:55:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997, 1998, 1999, 2000 4 * Copyright (c) 1997, 1998, 1999, 2000
5 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 5 * Bill Paul <wpaul@ee.columbia.edu>. 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.
@@ -66,27 +66,27 @@ @@ -66,27 +66,27 @@
66/* 66/*
67 * Ported to NetBSD and somewhat rewritten by Lennart Augustsson. 67 * Ported to NetBSD and somewhat rewritten by Lennart Augustsson.
68 */ 68 */
69 69
70/* 70/*
71 * TODO: 71 * TODO:
72 * better error messages from rxstat 72 * better error messages from rxstat
73 * more error checks 73 * more error checks
74 * investigate short rx problem 74 * investigate short rx problem
75 * proper cleanup on errors 75 * proper cleanup on errors
76 */ 76 */
77 77
78#include <sys/cdefs.h> 78#include <sys/cdefs.h>
79__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.186 2022/03/03 05:54:37 riastradh Exp $"); 79__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.187 2022/03/03 05:55:01 riastradh Exp $");
80 80
81#ifdef _KERNEL_OPT 81#ifdef _KERNEL_OPT
82#include "opt_usb.h" 82#include "opt_usb.h"
83#include "opt_inet.h" 83#include "opt_inet.h"
84#endif 84#endif
85 85
86#include <sys/param.h> 86#include <sys/param.h>
87 87
88#include <dev/usb/usbnet.h> 88#include <dev/usb/usbnet.h>
89#include <dev/usb/usbhist.h> 89#include <dev/usb/usbhist.h>
90#include <dev/usb/if_auereg.h> 90#include <dev/usb/if_auereg.h>
91 91
92#ifdef INET 92#ifdef INET
@@ -944,29 +944,26 @@ aue_uno_tx_prepare(struct usbnet *un, st @@ -944,29 +944,26 @@ aue_uno_tx_prepare(struct usbnet *un, st
944 944
945static int 945static int
946aue_uno_init(struct ifnet *ifp) 946aue_uno_init(struct ifnet *ifp)
947{ 947{
948 struct usbnet * const un = ifp->if_softc; 948 struct usbnet * const un = ifp->if_softc;
949 struct aue_softc *sc = usbnet_softc(un); 949 struct aue_softc *sc = usbnet_softc(un);
950 int i; 950 int i;
951 const u_char *eaddr; 951 const u_char *eaddr;
952 952
953 AUEHIST_FUNC(); 953 AUEHIST_FUNC();
954 AUEHIST_CALLARGSN(5, "aue%jd: enter link=%jd", 954 AUEHIST_CALLARGSN(5, "aue%jd: enter link=%jd",
955 device_unit(un->un_dev), usbnet_havelink(un), 0, 0); 955 device_unit(un->un_dev), usbnet_havelink(un), 0, 0);
956 956
957 if (usbnet_isdying(un)) 
958 return EIO; 
959 
960 /* Cancel pending I/O */ 957 /* Cancel pending I/O */
961 if (ifp->if_flags & IFF_RUNNING) 958 if (ifp->if_flags & IFF_RUNNING)
962 return 0; 959 return 0;
963 960
964 /* Reset the interface. */ 961 /* Reset the interface. */
965 aue_reset(sc); 962 aue_reset(sc);
966 963
967 eaddr = CLLADDR(ifp->if_sadl); 964 eaddr = CLLADDR(ifp->if_sadl);
968 for (i = 0; i < ETHER_ADDR_LEN; i++) 965 for (i = 0; i < ETHER_ADDR_LEN; i++)
969 aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]); 966 aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]);
970 967
971 /* If we want promiscuous mode, set the allframes bit. */ 968 /* If we want promiscuous mode, set the allframes bit. */
972 if (ifp->if_flags & IFF_PROMISC) 969 if (ifp->if_flags & IFF_PROMISC)

cvs diff -r1.145 -r1.146 src/sys/dev/usb/if_axe.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_axe.c 2022/03/03 05:54:37 1.145
+++ src/sys/dev/usb/if_axe.c 2022/03/03 05:55:01 1.146
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_axe.c,v 1.145 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_axe.c,v 1.146 2022/03/03 05:55:01 riastradh Exp $ */
2/* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */ 2/* $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg@openbsd.org> 5 * Copyright (c) 2005, 2006, 2007 Jonathan Gray <jsg@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
@@ -77,27 +77,27 @@ @@ -77,27 +77,27 @@
77 * (Adam Weinberger wanted me to name this driver if_gir.c.) 77 * (Adam Weinberger wanted me to name this driver if_gir.c.)
78 */ 78 */
79 79
80/* 80/*
81 * Ax88178 and Ax88772 support backported from the OpenBSD driver. 81 * Ax88178 and Ax88772 support backported from the OpenBSD driver.
82 * 2007/02/12, J.R. Oldroyd, fbsd@opal.com 82 * 2007/02/12, J.R. Oldroyd, fbsd@opal.com
83 * 83 *
84 * Manual here: 84 * Manual here:
85 * http://www.asix.com.tw/FrootAttach/datasheet/AX88178_datasheet_Rev10.pdf 85 * http://www.asix.com.tw/FrootAttach/datasheet/AX88178_datasheet_Rev10.pdf
86 * http://www.asix.com.tw/FrootAttach/datasheet/AX88772_datasheet_Rev10.pdf 86 * http://www.asix.com.tw/FrootAttach/datasheet/AX88772_datasheet_Rev10.pdf
87 */ 87 */
88 88
89#include <sys/cdefs.h> 89#include <sys/cdefs.h>
90__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.145 2022/03/03 05:54:37 riastradh Exp $"); 90__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.146 2022/03/03 05:55:01 riastradh Exp $");
91 91
92#ifdef _KERNEL_OPT 92#ifdef _KERNEL_OPT
93#include "opt_usb.h" 93#include "opt_usb.h"
94#include "opt_net_mpsafe.h" 94#include "opt_net_mpsafe.h"
95#endif 95#endif
96 96
97#include <sys/param.h> 97#include <sys/param.h>
98 98
99#include <dev/usb/usbnet.h> 99#include <dev/usb/usbnet.h>
100#include <dev/usb/usbhist.h> 100#include <dev/usb/usbhist.h>
101#include <dev/usb/if_axereg.h> 101#include <dev/usb/if_axereg.h>
102 102
103struct axe_type { 103struct axe_type {
@@ -1201,29 +1201,26 @@ axe_csum_cfg(struct axe_softc *sc) @@ -1201,29 +1201,26 @@ axe_csum_cfg(struct axe_softc *sc)
1201 csum1 |= AXE_RXCSUM_UDPV6; 1201 csum1 |= AXE_RXCSUM_UDPV6;
1202 axe_cmd(sc, AXE_772B_CMD_WRITE_RXCSUM, csum2, csum1, NULL); 1202 axe_cmd(sc, AXE_772B_CMD_WRITE_RXCSUM, csum2, csum1, NULL);
1203 } 1203 }
1204} 1204}
1205 1205
1206static int 1206static int
1207axe_uno_init(struct ifnet *ifp) 1207axe_uno_init(struct ifnet *ifp)
1208{ 1208{
1209 AXEHIST_FUNC(); AXEHIST_CALLED(); 1209 AXEHIST_FUNC(); AXEHIST_CALLED();
1210 struct usbnet * const un = ifp->if_softc; 1210 struct usbnet * const un = ifp->if_softc;
1211 struct axe_softc * const sc = usbnet_softc(un); 1211 struct axe_softc * const sc = usbnet_softc(un);
1212 int rxmode; 1212 int rxmode;
1213 1213
1214 if (usbnet_isdying(un)) 
1215 return EIO; 
1216 
1217 /* Cancel pending I/O */ 1214 /* Cancel pending I/O */
1218 usbnet_stop(un, ifp, 1); 1215 usbnet_stop(un, ifp, 1);
1219 1216
1220 /* Reset the ethernet interface. */ 1217 /* Reset the ethernet interface. */
1221 axe_reset(un); 1218 axe_reset(un);
1222 1219
1223#if 0 1220#if 0
1224 ret = asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_2 | 1221 ret = asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_2 |
1225 AX_GPIO_GPO2EN, 5, in_pm); 1222 AX_GPIO_GPO2EN, 5, in_pm);
1226#endif 1223#endif
1227 /* Set MAC address and transmitter IPG values. */ 1224 /* Set MAC address and transmitter IPG values. */
1228 if (AXE_IS_172(un)) { 1225 if (AXE_IS_172(un)) {
1229 axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, un->un_eaddr); 1226 axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, un->un_eaddr);

cvs diff -r1.89 -r1.90 src/sys/dev/usb/if_axen.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_axen.c 2022/03/03 05:54:37 1.89
+++ src/sys/dev/usb/if_axen.c 2022/03/03 05:55:01 1.90
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: if_axen.c,v 1.89 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_axen.c,v 1.90 2022/03/03 05:55:01 riastradh Exp $ */
2/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */ 2/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2013 Yojiro UO <yuo@openbsd.org> 5 * Copyright (c) 2013 Yojiro UO <yuo@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/* 20/*
21 * ASIX Electronics AX88178a USB 2.0 ethernet and AX88179 USB 3.0 Ethernet 21 * ASIX Electronics AX88178a USB 2.0 ethernet and AX88179 USB 3.0 Ethernet
22 * driver. 22 * driver.
23 */ 23 */
24 24
25#include <sys/cdefs.h> 25#include <sys/cdefs.h>
26__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.89 2022/03/03 05:54:37 riastradh Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.90 2022/03/03 05:55:01 riastradh 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 33
34#include <netinet/in.h> /* XXX for netinet/ip.h */ 34#include <netinet/in.h> /* XXX for netinet/ip.h */
35#include <netinet/ip.h> /* XXX for IP_MAXPACKET */ 35#include <netinet/ip.h> /* XXX for IP_MAXPACKET */
36 36
37#include <dev/usb/usbnet.h> 37#include <dev/usb/usbnet.h>
38 38
39#include <dev/usb/if_axenreg.h> 39#include <dev/usb/if_axenreg.h>
@@ -866,29 +866,26 @@ axen_uno_tx_prepare(struct usbnet *un, s @@ -866,29 +866,26 @@ axen_uno_tx_prepare(struct usbnet *un, s
866 m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + sizeof(hdr)); 866 m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + sizeof(hdr));
867 867
868 return length; 868 return length;
869} 869}
870 870
871static int 871static int
872axen_uno_init(struct ifnet *ifp) 872axen_uno_init(struct ifnet *ifp)
873{ 873{
874 struct usbnet * const un = ifp->if_softc; 874 struct usbnet * const un = ifp->if_softc;
875 uint16_t rxmode; 875 uint16_t rxmode;
876 uint16_t wval; 876 uint16_t wval;
877 uint8_t bval; 877 uint8_t bval;
878 878
879 if (usbnet_isdying(un)) 
880 return EIO; 
881 
882 /* Cancel pending I/O */ 879 /* Cancel pending I/O */
883 usbnet_stop(un, ifp, 1); 880 usbnet_stop(un, ifp, 1);
884 881
885 /* Reset the ethernet interface. */ 882 /* Reset the ethernet interface. */
886 axen_reset(un); 883 axen_reset(un);
887 884
888 /* XXX: ? */ 885 /* XXX: ? */
889 bval = 0x01; 886 bval = 0x01;
890 axen_cmd(un, AXEN_CMD_MAC_WRITE, 1, AXEN_UNK_28, &bval); 887 axen_cmd(un, AXEN_CMD_MAC_WRITE, 1, AXEN_UNK_28, &bval);
891 888
892 /* Configure offloading engine. */ 889 /* Configure offloading engine. */
893 axen_setoe_locked(un); 890 axen_setoe_locked(un);
894 891

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

--- src/sys/dev/usb/if_cdce.c 2022/03/03 05:52:20 1.74
+++ src/sys/dev/usb/if_cdce.c 2022/03/03 05:55:01 1.75
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_cdce.c,v 1.74 2022/03/03 05:52:20 riastradh Exp $ */ 1/* $NetBSD: if_cdce.c,v 1.75 2022/03/03 05:55:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul@windriver.com> 4 * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul@windriver.com>
5 * Copyright (c) 2003 Craig Boston 5 * Copyright (c) 2003 Craig Boston
6 * Copyright (c) 2004 Daniel Hartmeier 6 * Copyright (c) 2004 Daniel Hartmeier
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 30 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
31 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 31 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
33 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 33 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
34 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 */ 35 */
36 36
37/* 37/*
38 * USB Communication Device Class (Ethernet Networking Control Model) 38 * USB Communication Device Class (Ethernet Networking Control Model)
39 * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf 39 * http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
40 */ 40 */
41 41
42#include <sys/cdefs.h> 42#include <sys/cdefs.h>
43__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.74 2022/03/03 05:52:20 riastradh Exp $"); 43__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.75 2022/03/03 05:55:01 riastradh Exp $");
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#include <dev/usb/usbcdc.h> 48#include <dev/usb/usbcdc.h>
49 49
50#include <dev/usb/if_cdcereg.h> 50#include <dev/usb/if_cdcereg.h>
51 51
52struct cdce_type { 52struct cdce_type {
53 struct usb_devno cdce_dev; 53 struct usb_devno cdce_dev;
54 uint16_t cdce_flags; 54 uint16_t cdce_flags;
55#define CDCE_ZAURUS 1 55#define CDCE_ZAURUS 1
56#define CDCE_NO_UNION 2 56#define CDCE_NO_UNION 2
@@ -251,33 +251,29 @@ cdce_attach(device_t parent, device_t se @@ -251,33 +251,29 @@ cdce_attach(device_t parent, device_t se
251 } 251 }
252 252
253 usbnet_attach(un, "cdcedet"); 253 usbnet_attach(un, "cdcedet");
254 usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST, 254 usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
255 0, NULL); 255 0, NULL);
256} 256}
257 257
258static int 258static int
259cdce_uno_init(struct ifnet *ifp) 259cdce_uno_init(struct ifnet *ifp)
260{ 260{
261 struct usbnet *un = ifp->if_softc; 261 struct usbnet *un = ifp->if_softc;
262 int rv; 262 int rv;
263 263
264 if (usbnet_isdying(un)) 264 usbnet_stop(un, ifp, 1);
265 rv = EIO; 265 rv = usbnet_init_rx_tx(un);
266 else { 266 usbnet_set_link(un, rv == 0);
267 usbnet_stop(un, ifp, 1); 
268 rv = usbnet_init_rx_tx(un); 
269 usbnet_set_link(un, rv == 0); 
270 } 
271 267
272 return rv; 268 return rv;
273} 269}
274 270
275static void 271static void
276cdce_uno_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len) 272cdce_uno_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len)
277{ 273{
278 struct ifnet *ifp = usbnet_ifp(un); 274 struct ifnet *ifp = usbnet_ifp(un);
279 275
280 /* Strip off CRC added by Zaurus, if present */ 276 /* Strip off CRC added by Zaurus, if present */
281 if (un->un_flags & CDCE_ZAURUS && total_len > 4) 277 if (un->un_flags & CDCE_ZAURUS && total_len > 4)
282 total_len -= 4; 278 total_len -= 4;
283 279

cvs diff -r1.102 -r1.103 src/sys/dev/usb/if_cue.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_cue.c 2022/03/03 05:54:37 1.102
+++ src/sys/dev/usb/if_cue.c 2022/03/03 05:55:01 1.103
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_cue.c,v 1.102 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_cue.c,v 1.103 2022/03/03 05:55:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997, 1998, 1999, 2000 4 * Copyright (c) 1997, 1998, 1999, 2000
5 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 5 * Bill Paul <wpaul@ee.columbia.edu>. 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.
@@ -47,27 +47,27 @@ @@ -47,27 +47,27 @@
47 * The CATC USB-EL1210A provides USB ethernet support at 10Mbps. The 47 * The CATC USB-EL1210A provides USB ethernet support at 10Mbps. The
48 * RX filter uses a 512-bit multicast hash table, single perfect entry 48 * RX filter uses a 512-bit multicast hash table, single perfect entry
49 * for the station address, and promiscuous mode. Unlike the ADMtek 49 * for the station address, and promiscuous mode. Unlike the ADMtek
50 * and KLSI chips, the CATC ASIC supports read and write combining 50 * and KLSI chips, the CATC ASIC supports read and write combining
51 * mode where multiple packets can be transferred using a single bulk 51 * mode where multiple packets can be transferred using a single bulk
52 * transaction, which helps performance a great deal. 52 * transaction, which helps performance a great deal.
53 */ 53 */
54 54
55/* 55/*
56 * Ported to NetBSD and somewhat rewritten by Lennart Augustsson. 56 * Ported to NetBSD and somewhat rewritten by Lennart Augustsson.
57 */ 57 */
58 58
59#include <sys/cdefs.h> 59#include <sys/cdefs.h>
60__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.102 2022/03/03 05:54:37 riastradh Exp $"); 60__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.103 2022/03/03 05:55:01 riastradh Exp $");
61 61
62#ifdef _KERNEL_OPT 62#ifdef _KERNEL_OPT
63#include "opt_inet.h" 63#include "opt_inet.h"
64#include "opt_usb.h" 64#include "opt_usb.h"
65#endif 65#endif
66 66
67#include <sys/param.h> 67#include <sys/param.h>
68 68
69#include <dev/usb/usbnet.h> 69#include <dev/usb/usbnet.h>
70#include <dev/usb/if_cuereg.h> 70#include <dev/usb/if_cuereg.h>
71 71
72#ifdef INET 72#ifdef INET
73#include <netinet/in.h> 73#include <netinet/in.h>
@@ -607,29 +607,26 @@ cue_uno_tx_prepare(struct usbnet *un, st @@ -607,29 +607,26 @@ cue_uno_tx_prepare(struct usbnet *un, st
607 607
608 return total_len; 608 return total_len;
609} 609}
610 610
611static int 611static int
612cue_uno_init(struct ifnet *ifp) 612cue_uno_init(struct ifnet *ifp)
613{ 613{
614 struct usbnet * const un = ifp->if_softc; 614 struct usbnet * const un = ifp->if_softc;
615 int i, ctl; 615 int i, ctl;
616 const u_char *eaddr; 616 const u_char *eaddr;
617 617
618 DPRINTFN(10,("%s: %s: enter\n", device_xname(un->un_dev),__func__)); 618 DPRINTFN(10,("%s: %s: enter\n", device_xname(un->un_dev),__func__));
619 619
620 if (usbnet_isdying(un)) 
621 return ENXIO; 
622 
623 /* Cancel pending I/O */ 620 /* Cancel pending I/O */
624 usbnet_stop(un, ifp, 1); 621 usbnet_stop(un, ifp, 1);
625 622
626 /* Reset the interface. */ 623 /* Reset the interface. */
627#if 1 624#if 1
628 cue_reset(un); 625 cue_reset(un);
629#endif 626#endif
630 627
631 /* Set advanced operation modes. */ 628 /* Set advanced operation modes. */
632 cue_csr_write_1(un, CUE_ADVANCED_OPMODES, 629 cue_csr_write_1(un, CUE_ADVANCED_OPMODES,
633 CUE_AOP_EMBED_RXLEN | 0x03); /* 1 wait state */ 630 CUE_AOP_EMBED_RXLEN | 0x03); /* 1 wait state */
634 631
635 eaddr = CLLADDR(ifp->if_sadl); 632 eaddr = CLLADDR(ifp->if_sadl);

cvs diff -r1.114 -r1.115 src/sys/dev/usb/if_kue.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_kue.c 2022/03/03 05:53:33 1.114
+++ src/sys/dev/usb/if_kue.c 2022/03/03 05:55:01 1.115
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_kue.c,v 1.114 2022/03/03 05:53:33 riastradh Exp $ */ 1/* $NetBSD: if_kue.c,v 1.115 2022/03/03 05:55:01 riastradh Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997, 1998, 1999, 2000 4 * Copyright (c) 1997, 1998, 1999, 2000
5 * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 5 * Bill Paul <wpaul@ee.columbia.edu>. 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.
@@ -61,27 +61,27 @@ @@ -61,27 +61,27 @@
61 * powered on and retain its firmware. In this case, we don't need 61 * powered on and retain its firmware. In this case, we don't need
62 * to load the firmware a second time. 62 * to load the firmware a second time.
63 * 63 *
64 * Special thanks to Rob Furr for providing an ADS Technologies 64 * Special thanks to Rob Furr for providing an ADS Technologies
65 * adapter for development and testing. No monkeys were harmed during 65 * adapter for development and testing. No monkeys were harmed during
66 * the development of this driver. 66 * the development of this driver.
67 */ 67 */
68 68
69/* 69/*
70 * Ported to NetBSD and somewhat rewritten by Lennart Augustsson. 70 * Ported to NetBSD and somewhat rewritten by Lennart Augustsson.
71 */ 71 */
72 72
73#include <sys/cdefs.h> 73#include <sys/cdefs.h>
74__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.114 2022/03/03 05:53:33 riastradh Exp $"); 74__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.115 2022/03/03 05:55:01 riastradh Exp $");
75 75
76#ifdef _KERNEL_OPT 76#ifdef _KERNEL_OPT
77#include "opt_inet.h" 77#include "opt_inet.h"
78#include "opt_usb.h" 78#include "opt_usb.h"
79#endif 79#endif
80 80
81#include <sys/param.h> 81#include <sys/param.h>
82#include <sys/kmem.h> 82#include <sys/kmem.h>
83 83
84#include <dev/usb/usbnet.h> 84#include <dev/usb/usbnet.h>
85 85
86#ifdef INET 86#ifdef INET
87#include <netinet/in.h> 87#include <netinet/in.h>
@@ -589,29 +589,26 @@ kue_uno_tx_prepare(struct usbnet *un, st @@ -589,29 +589,26 @@ kue_uno_tx_prepare(struct usbnet *un, st
589 589
590 return total_len; 590 return total_len;
591} 591}
592 592
593static int 593static int
594kue_uno_init(struct ifnet *ifp) 594kue_uno_init(struct ifnet *ifp)
595{ 595{
596 struct usbnet * const un = ifp->if_softc; 596 struct usbnet * const un = ifp->if_softc;
597 struct kue_softc *sc = usbnet_softc(un); 597 struct kue_softc *sc = usbnet_softc(un);
598 uint8_t eaddr[ETHER_ADDR_LEN]; 598 uint8_t eaddr[ETHER_ADDR_LEN];
599 599
600 DPRINTFN(5,("%s: %s: enter\n", device_xname(un->un_dev),__func__)); 600 DPRINTFN(5,("%s: %s: enter\n", device_xname(un->un_dev),__func__));
601 601
602 if (usbnet_isdying(un)) 
603 return EIO; 
604 
605 /* Cancel pending I/O */ 602 /* Cancel pending I/O */
606 usbnet_stop(un, ifp, 1); 603 usbnet_stop(un, ifp, 1);
607 604
608 memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr)); 605 memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr));
609 /* Set MAC address */ 606 /* Set MAC address */
610 kue_ctl(un, KUE_CTL_WRITE, KUE_CMD_SET_MAC, 0, eaddr, ETHER_ADDR_LEN); 607 kue_ctl(un, KUE_CTL_WRITE, KUE_CMD_SET_MAC, 0, eaddr, ETHER_ADDR_LEN);
611 608
612 sc->kue_rxfilt = KUE_RXFILT_UNICAST | KUE_RXFILT_BROADCAST; 609 sc->kue_rxfilt = KUE_RXFILT_UNICAST | KUE_RXFILT_BROADCAST;
613 610
614 /* I'm not sure how to tune these. */ 611 /* I'm not sure how to tune these. */
615#if 0 612#if 0
616 /* 613 /*
617 * Leave this one alone for now; setting it 614 * Leave this one alone for now; setting it

cvs diff -r1.17 -r1.18 src/sys/dev/usb/if_mos.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_mos.c 2022/03/03 05:54:21 1.17
+++ src/sys/dev/usb/if_mos.c 2022/03/03 05:55:01 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_mos.c,v 1.17 2022/03/03 05:54:21 riastradh Exp $ */ 1/* $NetBSD: if_mos.c,v 1.18 2022/03/03 05:55:01 riastradh Exp $ */
2/* $OpenBSD: if_mos.c,v 1.40 2019/07/07 06:40:10 kevlo Exp $ */ 2/* $OpenBSD: if_mos.c,v 1.40 2019/07/07 06:40:10 kevlo Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2008 Johann Christian Rode <jcrode@gmx.net> 5 * Copyright (c) 2008 Johann Christian Rode <jcrode@gmx.net>
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
@@ -62,27 +62,27 @@ @@ -62,27 +62,27 @@
62 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 62 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
63 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 63 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
64 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 64 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
65 * THE POSSIBILITY OF SUCH DAMAGE. 65 * THE POSSIBILITY OF SUCH DAMAGE.
66 */ 66 */
67 67
68/* 68/*
69 * Moschip MCS7730/MCS7830/MCS7832 USB to Ethernet controller  69 * Moschip MCS7730/MCS7830/MCS7832 USB to Ethernet controller
70 * The datasheet is available at the following URL:  70 * The datasheet is available at the following URL:
71 * http://www.moschip.com/data/products/MCS7830/Data%20Sheet_7830.pdf 71 * http://www.moschip.com/data/products/MCS7830/Data%20Sheet_7830.pdf
72 */ 72 */
73 73
74#include <sys/cdefs.h> 74#include <sys/cdefs.h>
75__KERNEL_RCSID(0, "$NetBSD: if_mos.c,v 1.17 2022/03/03 05:54:21 riastradh Exp $"); 75__KERNEL_RCSID(0, "$NetBSD: if_mos.c,v 1.18 2022/03/03 05:55:01 riastradh Exp $");
76 76
77#include <sys/param.h> 77#include <sys/param.h>
78 78
79#include <dev/usb/usbnet.h> 79#include <dev/usb/usbnet.h>
80#include <dev/usb/if_mosreg.h> 80#include <dev/usb/if_mosreg.h>
81 81
82#define MOS_PAUSE_REWRITES 3 82#define MOS_PAUSE_REWRITES 3
83 83
84#define MOS_TIMEOUT 1000 84#define MOS_TIMEOUT 1000
85 85
86#define MOS_RX_LIST_CNT 1 86#define MOS_RX_LIST_CNT 1
87#define MOS_TX_LIST_CNT 1 87#define MOS_TX_LIST_CNT 1
88 88
@@ -722,29 +722,26 @@ mos_uno_tx_prepare(struct usbnet *un, st @@ -722,29 +722,26 @@ mos_uno_tx_prepare(struct usbnet *un, st
722 DPRINTFN(5,("%s: %s: len %u\n", 722 DPRINTFN(5,("%s: %s: len %u\n",
723 device_xname(un->un_dev), __func__, length)); 723 device_xname(un->un_dev), __func__, length));
724 724
725 return length; 725 return length;
726} 726}
727 727
728static int 728static int
729mos_uno_init(struct ifnet *ifp) 729mos_uno_init(struct ifnet *ifp)
730{ 730{
731 struct usbnet * const un = ifp->if_softc; 731 struct usbnet * const un = ifp->if_softc;
732 u_int8_t rxmode; 732 u_int8_t rxmode;
733 unsigned char ipgs[2]; 733 unsigned char ipgs[2];
734 734
735 if (usbnet_isdying(un)) 
736 return EIO; 
737 
738 /* Cancel pending I/O */ 735 /* Cancel pending I/O */
739 usbnet_stop(un, ifp, 1); 736 usbnet_stop(un, ifp, 1);
740 737
741 /* Reset the ethernet interface. */ 738 /* Reset the ethernet interface. */
742 mos_reset(un); 739 mos_reset(un);
743 740
744 /* Write MAC address. */ 741 /* Write MAC address. */
745 mos_writemac(un); 742 mos_writemac(un);
746 743
747 /* Read and set transmitter IPG values */ 744 /* Read and set transmitter IPG values */
748 ipgs[0] = mos_reg_read_1(un, MOS_IPG0); 745 ipgs[0] = mos_reg_read_1(un, MOS_IPG0);
749 ipgs[1] = mos_reg_read_1(un, MOS_IPG1); 746 ipgs[1] = mos_reg_read_1(un, MOS_IPG1);
750 mos_reg_write_1(un, MOS_IPG0, ipgs[0]); 747 mos_reg_write_1(un, MOS_IPG0, ipgs[0]);

cvs diff -r1.77 -r1.78 src/sys/dev/usb/if_mue.c (expand / switch to unified diff)

--- src/sys/dev/usb/if_mue.c 2022/03/03 05:54:37 1.77
+++ src/sys/dev/usb/if_mue.c 2022/03/03 05:55:01 1.78
@@ -1,36 +1,36 @@ @@ -1,36 +1,36 @@
1/* $NetBSD: if_mue.c,v 1.77 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_mue.c,v 1.78 2022/03/03 05:55:01 riastradh Exp $ */
2/* $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $ */ 2/* $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2018 Kevin Lo <kevlo@openbsd.org> 5 * Copyright (c) 2018 Kevin Lo <kevlo@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/* Driver for Microchip LAN7500/LAN7800 chipsets. */ 20/* Driver for Microchip LAN7500/LAN7800 chipsets. */
21 21
22#include <sys/cdefs.h> 22#include <sys/cdefs.h>
23__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.77 2022/03/03 05:54:37 riastradh Exp $"); 23__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.78 2022/03/03 05:55:01 riastradh Exp $");
24 24
25#ifdef _KERNEL_OPT 25#ifdef _KERNEL_OPT
26#include "opt_usb.h" 26#include "opt_usb.h"
27#include "opt_inet.h" 27#include "opt_inet.h"
28#endif 28#endif
29 29
30#include <sys/param.h> 30#include <sys/param.h>
31 31
32#include <dev/usb/usbnet.h> 32#include <dev/usb/usbnet.h>
33 33
34#include <dev/usb/if_muereg.h> 34#include <dev/usb/if_muereg.h>
35#include <dev/usb/if_muevar.h> 35#include <dev/usb/if_muevar.h>
36 36
@@ -1223,31 +1223,26 @@ mue_uno_rx_loop(struct usbnet *un, struc @@ -1223,31 +1223,26 @@ mue_uno_rx_loop(struct usbnet *un, struc
1223 pktlen = roundup(pktlen + sizeof(*hdrp), 4); 1223 pktlen = roundup(pktlen + sizeof(*hdrp), 4);
1224 if (pktlen > total_len) 1224 if (pktlen > total_len)
1225 pktlen = total_len; 1225 pktlen = total_len;
1226 total_len -= pktlen; 1226 total_len -= pktlen;
1227 buf += pktlen; 1227 buf += pktlen;
1228 } while (total_len > 0); 1228 } while (total_len > 0);
1229} 1229}
1230 1230
1231static int 1231static int
1232mue_uno_init(struct ifnet *ifp) 1232mue_uno_init(struct ifnet *ifp)
1233{ 1233{
1234 struct usbnet * const un = ifp->if_softc; 1234 struct usbnet * const un = ifp->if_softc;
1235 1235
1236 if (usbnet_isdying(un)) { 
1237 DPRINTF(un, "dying\n"); 
1238 return EIO; 
1239 } 
1240 
1241 /* Cancel pending I/O and free all TX/RX buffers. */ 1236 /* Cancel pending I/O and free all TX/RX buffers. */
1242 if (ifp->if_flags & IFF_RUNNING) 1237 if (ifp->if_flags & IFF_RUNNING)
1243 usbnet_stop(un, ifp, 1); 1238 usbnet_stop(un, ifp, 1);
1244 1239
1245 mue_reset(un); 1240 mue_reset(un);
1246 1241
1247 /* Set MAC address. */ 1242 /* Set MAC address. */
1248 mue_set_macaddr(un); 1243 mue_set_macaddr(un);
1249 1244
1250 /* TCP/UDP checksum offload engines. */ 1245 /* TCP/UDP checksum offload engines. */
1251 mue_sethwcsum_locked(un); 1246 mue_sethwcsum_locked(un);
1252 1247
1253 /* Set MTU. */ 1248 /* Set MTU. */

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

--- src/sys/dev/usb/if_smsc.c 2022/03/03 05:54:37 1.87
+++ src/sys/dev/usb/if_smsc.c 2022/03/03 05:55:01 1.88
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_smsc.c,v 1.87 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_smsc.c,v 1.88 2022/03/03 05:55:01 riastradh 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.87 2022/03/03 05:54:37 riastradh Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.88 2022/03/03 05:55:01 riastradh 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"
@@ -545,29 +545,26 @@ smsc_reset(struct smsc_softc *sc) @@ -545,29 +545,26 @@ smsc_reset(struct smsc_softc *sc)
545 /* Wait a little while for the chip to get its brains in order. */ 545 /* Wait a little while for the chip to get its brains in order. */
546 DELAY(1000); 546 DELAY(1000);
547 547
548 /* Reinitialize controller to achieve full reset. */ 548 /* Reinitialize controller to achieve full reset. */
549 smsc_chip_init(un); 549 smsc_chip_init(un);
550} 550}
551 551
552static int 552static int
553smsc_uno_init(struct ifnet *ifp) 553smsc_uno_init(struct ifnet *ifp)
554{ 554{
555 struct usbnet * const un = ifp->if_softc; 555 struct usbnet * const un = ifp->if_softc;
556 struct smsc_softc * const sc = usbnet_softc(un); 556 struct smsc_softc * const sc = usbnet_softc(un);
557 557
558 if (usbnet_isdying(un)) 
559 return EIO; 
560 
561 /* Cancel pending I/O */ 558 /* Cancel pending I/O */
562 usbnet_stop(un, ifp, 1); 559 usbnet_stop(un, ifp, 1);
563 560
564 /* Reset the ethernet interface. */ 561 /* Reset the ethernet interface. */
565 smsc_reset(sc); 562 smsc_reset(sc);
566 563
567 /* TCP/UDP checksum offload engines. */ 564 /* TCP/UDP checksum offload engines. */
568 smsc_setoe_locked(un); 565 smsc_setoe_locked(un);
569 566
570 return usbnet_init_rx_tx(un); 567 return usbnet_init_rx_tx(un);
571} 568}
572 569
573static void 570static void

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

--- src/sys/dev/usb/if_udav.c 2022/03/03 05:54:37 1.92
+++ src/sys/dev/usb/if_udav.c 2022/03/03 05:55:01 1.93
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_udav.c,v 1.92 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_udav.c,v 1.93 2022/03/03 05:55:01 riastradh 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.92 2022/03/03 05:54:37 riastradh Exp $"); 48__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.93 2022/03/03 05:55:01 riastradh 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 *);
@@ -461,30 +461,26 @@ udav_csr_write1(struct usbnet *un, int o @@ -461,30 +461,26 @@ udav_csr_write1(struct usbnet *un, int o
461 return err; 461 return err;
462} 462}
463 463
464static int 464static int
465udav_uno_init(struct ifnet *ifp) 465udav_uno_init(struct ifnet *ifp)
466{ 466{
467 struct usbnet * const un = ifp->if_softc; 467 struct usbnet * const un = ifp->if_softc;
468 struct mii_data * const mii = usbnet_mii(un); 468 struct mii_data * const mii = usbnet_mii(un);
469 uint8_t eaddr[ETHER_ADDR_LEN]; 469 uint8_t eaddr[ETHER_ADDR_LEN];
470 int rc = 0; 470 int rc = 0;
471 471
472 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 472 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
473 473
474 if (usbnet_isdying(un)) { 
475 return EIO; 
476 } 
477 
478 /* Cancel pending I/O and free all TX/RX buffers */ 474 /* Cancel pending I/O and free all TX/RX buffers */
479 if (ifp->if_flags & IFF_RUNNING) 475 if (ifp->if_flags & IFF_RUNNING)
480 usbnet_stop(un, ifp, 1); 476 usbnet_stop(un, ifp, 1);
481 477
482 memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr)); 478 memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr));
483 udav_csr_write(un, UDAV_PAR, eaddr, ETHER_ADDR_LEN); 479 udav_csr_write(un, UDAV_PAR, eaddr, ETHER_ADDR_LEN);
484 480
485 /* Initialize network control register */ 481 /* Initialize network control register */
486 /* Disable loopback */ 482 /* Disable loopback */
487 UDAV_CLRBIT(un, UDAV_NCR, UDAV_NCR_LBK0 | UDAV_NCR_LBK1); 483 UDAV_CLRBIT(un, UDAV_NCR, UDAV_NCR_LBK0 | UDAV_NCR_LBK1);
488 484
489 /* Initialize RX control register */ 485 /* Initialize RX control register */
490 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_DIS_LONG | UDAV_RCR_DIS_CRC); 486 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_DIS_LONG | UDAV_RCR_DIS_CRC);

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

--- src/sys/dev/usb/if_upl.c 2022/03/03 05:50:22 1.72
+++ src/sys/dev/usb/if_upl.c 2022/03/03 05:55:01 1.73
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_upl.c,v 1.72 2022/03/03 05:50:22 riastradh Exp $ */ 1/* $NetBSD: if_upl.c,v 1.73 2022/03/03 05:55:01 riastradh 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.72 2022/03/03 05:50:22 riastradh Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.73 2022/03/03 05:55:01 riastradh 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
@@ -247,30 +247,27 @@ upl_uno_tx_prepare(struct usbnet *un, st @@ -247,30 +247,27 @@ upl_uno_tx_prepare(struct usbnet *un, st
247 247
248 DPRINTFN(10,("%s: %s: total_len=%d\n", 248 DPRINTFN(10,("%s: %s: total_len=%d\n",
249 device_xname(un->un_dev), __func__, total_len)); 249 device_xname(un->un_dev), __func__, total_len));
250 250
251 return total_len; 251 return total_len;
252} 252}
253 253
254static int 254static int
255upl_uno_init(struct ifnet *ifp) 255upl_uno_init(struct ifnet *ifp)
256{ 256{
257 struct usbnet * const un = ifp->if_softc; 257 struct usbnet * const un = ifp->if_softc;
258 int rv; 258 int rv;
259 259
260 if (usbnet_isdying(un)) 260 rv = usbnet_init_rx_tx(un);
261 rv = EIO; 
262 else 
263 rv = usbnet_init_rx_tx(un); 
264 261
265 return rv; 262 return rv;
266} 263}
267 264
268static int 265static int
269upl_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) 266upl_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
270{ 267{
271 if (cmd == SIOCSIFMTU) { 268 if (cmd == SIOCSIFMTU) {
272 struct ifreq *ifr = data; 269 struct ifreq *ifr = data;
273 270
274 if (ifr->ifr_mtu > UPL_BUFSZ) 271 if (ifr->ifr_mtu > UPL_BUFSZ)
275 return EINVAL; 272 return EINVAL;
276 } 273 }

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

--- src/sys/dev/usb/if_ure.c 2022/03/03 05:54:37 1.52
+++ src/sys/dev/usb/if_ure.c 2022/03/03 05:55:01 1.53
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_ure.c,v 1.52 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_ure.c,v 1.53 2022/03/03 05:55:01 riastradh 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.52 2022/03/03 05:54:37 riastradh Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.53 2022/03/03 05:55:01 riastradh 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
@@ -403,29 +403,26 @@ ure_reset(struct usbnet *un) @@ -403,29 +403,26 @@ ure_reset(struct usbnet *un)
403 break; 403 break;
404 usbd_delay_ms(un->un_udev, 10); 404 usbd_delay_ms(un->un_udev, 10);
405 } 405 }
406 if (i == URE_TIMEOUT) 406 if (i == URE_TIMEOUT)
407 URE_PRINTF(un, "reset never completed\n"); 407 URE_PRINTF(un, "reset never completed\n");
408} 408}
409 409
410static int 410static int
411ure_uno_init(struct ifnet *ifp) 411ure_uno_init(struct ifnet *ifp)
412{ 412{
413 struct usbnet * const un = ifp->if_softc; 413 struct usbnet * const un = ifp->if_softc;
414 uint8_t eaddr[8]; 414 uint8_t eaddr[8];
415 415
416 if (usbnet_isdying(un)) 
417 return EIO; 
418 
419 /* Cancel pending I/O. */ 416 /* Cancel pending I/O. */
420 if (ifp->if_flags & IFF_RUNNING) 417 if (ifp->if_flags & IFF_RUNNING)
421 usbnet_stop(un, ifp, 1); 418 usbnet_stop(un, ifp, 1);
422 419
423 /* Set MAC address. */ 420 /* Set MAC address. */
424 memset(eaddr, 0, sizeof(eaddr)); 421 memset(eaddr, 0, sizeof(eaddr));
425 memcpy(eaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN); 422 memcpy(eaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN);
426 ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG); 423 ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG);
427 ure_write_mem(un, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES, 424 ure_write_mem(un, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES,
428 eaddr, 8); 425 eaddr, 8);
429 ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML); 426 ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML);
430 427
431 /* Reset the packet filter. */ 428 /* Reset the packet filter. */

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

--- src/sys/dev/usb/if_url.c 2022/03/03 05:54:37 1.91
+++ src/sys/dev/usb/if_url.c 2022/03/03 05:55:01 1.92
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_url.c,v 1.91 2022/03/03 05:54:37 riastradh Exp $ */ 1/* $NetBSD: if_url.c,v 1.92 2022/03/03 05:55:01 riastradh 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.91 2022/03/03 05:54:37 riastradh Exp $"); 47__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.92 2022/03/03 05:55:01 riastradh 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
@@ -360,29 +360,26 @@ url_csr_write_4(struct usbnet *un, int r @@ -360,29 +360,26 @@ url_csr_write_4(struct usbnet *un, int r
360 360
361 return url_mem(un, URL_CMD_WRITEMEM, reg, &val, 4) ? -1 : 0; 361 return url_mem(un, URL_CMD_WRITEMEM, reg, &val, 4) ? -1 : 0;
362} 362}
363 363
364static int 364static int
365url_uno_init(struct ifnet *ifp) 365url_uno_init(struct ifnet *ifp)
366{ 366{
367 struct usbnet * const un = ifp->if_softc; 367 struct usbnet * const un = ifp->if_softc;
368 const u_char *eaddr; 368 const u_char *eaddr;
369 int i; 369 int i;
370 370
371 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 371 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
372 372
373 if (usbnet_isdying(un)) 
374 return EIO; 
375 
376 /* Cancel pending I/O and free all TX/RX buffers */ 373 /* Cancel pending I/O and free all TX/RX buffers */
377 usbnet_stop(un, ifp, 1); 374 usbnet_stop(un, ifp, 1);
378 375
379 eaddr = CLLADDR(ifp->if_sadl); 376 eaddr = CLLADDR(ifp->if_sadl);
380 for (i = 0; i < ETHER_ADDR_LEN; i++) 377 for (i = 0; i < ETHER_ADDR_LEN; i++)
381 url_csr_write_1(un, URL_IDR0 + i, eaddr[i]); 378 url_csr_write_1(un, URL_IDR0 + i, eaddr[i]);
382 379
383 /* Init transmission control register */ 380 /* Init transmission control register */
384 URL_CLRBIT(un, URL_TCR, 381 URL_CLRBIT(un, URL_TCR,
385 URL_TCR_TXRR1 | URL_TCR_TXRR0 | 382 URL_TCR_TXRR1 | URL_TCR_TXRR0 |
386 URL_TCR_IFG1 | URL_TCR_IFG0 | 383 URL_TCR_IFG1 | URL_TCR_IFG0 |
387 URL_TCR_NOCRC); 384 URL_TCR_NOCRC);
388 385