usbnet drivers: Prune dead IFF_RUNNING branches in *_uno_init. usbnet(9) guarantees !IFF_RUNNING now before calling it.diff -r1.187 -r1.188 src/sys/dev/usb/if_aue.c
(riastradh)
--- src/sys/dev/usb/if_aue.c 2022/03/03 05:55:01 1.187
+++ src/sys/dev/usb/if_aue.c 2022/03/03 05:55:19 1.188
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_aue.c,v 1.187 2022/03/03 05:55:01 riastradh Exp $ */ | 1 | /* $NetBSD: if_aue.c,v 1.188 2022/03/03 05:55:19 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.187 2022/03/03 05:55:01 riastradh Exp $"); | 79 | __KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.188 2022/03/03 05:55:19 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,30 +944,26 @@ aue_uno_tx_prepare(struct usbnet *un, st | @@ -944,30 +944,26 @@ aue_uno_tx_prepare(struct usbnet *un, st | |||
944 | 944 | |||
945 | static int | 945 | static int | |
946 | aue_uno_init(struct ifnet *ifp) | 946 | aue_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 | /* Cancel pending I/O */ | |||
958 | if (ifp->if_flags & IFF_RUNNING) | |||
959 | return 0; | |||
960 | ||||
961 | /* Reset the interface. */ | 957 | /* Reset the interface. */ | |
962 | aue_reset(sc); | 958 | aue_reset(sc); | |
963 | 959 | |||
964 | eaddr = CLLADDR(ifp->if_sadl); | 960 | eaddr = CLLADDR(ifp->if_sadl); | |
965 | for (i = 0; i < ETHER_ADDR_LEN; i++) | 961 | for (i = 0; i < ETHER_ADDR_LEN; i++) | |
966 | aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]); | 962 | aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]); | |
967 | 963 | |||
968 | /* If we want promiscuous mode, set the allframes bit. */ | 964 | /* If we want promiscuous mode, set the allframes bit. */ | |
969 | if (ifp->if_flags & IFF_PROMISC) | 965 | if (ifp->if_flags & IFF_PROMISC) | |
970 | AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); | 966 | AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); | |
971 | else | 967 | else | |
972 | AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); | 968 | AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); | |
973 | 969 |
--- src/sys/dev/usb/if_mue.c 2022/03/03 05:55:01 1.78
+++ src/sys/dev/usb/if_mue.c 2022/03/03 05:55:19 1.79
@@ -1,36 +1,36 @@ | @@ -1,36 +1,36 @@ | |||
1 | /* $NetBSD: if_mue.c,v 1.78 2022/03/03 05:55:01 riastradh Exp $ */ | 1 | /* $NetBSD: if_mue.c,v 1.79 2022/03/03 05:55:19 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.78 2022/03/03 05:55:01 riastradh Exp $"); | 23 | __KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.79 2022/03/03 05:55:19 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,30 +1223,26 @@ mue_uno_rx_loop(struct usbnet *un, struc | @@ -1223,30 +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 | |||
1231 | static int | 1231 | static int | |
1232 | mue_uno_init(struct ifnet *ifp) | 1232 | mue_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 | /* Cancel pending I/O and free all TX/RX buffers. */ | |||
1237 | if (ifp->if_flags & IFF_RUNNING) | |||
1238 | usbnet_stop(un, ifp, 1); | |||
1239 | ||||
1240 | mue_reset(un); | 1236 | mue_reset(un); | |
1241 | 1237 | |||
1242 | /* Set MAC address. */ | 1238 | /* Set MAC address. */ | |
1243 | mue_set_macaddr(un); | 1239 | mue_set_macaddr(un); | |
1244 | 1240 | |||
1245 | /* TCP/UDP checksum offload engines. */ | 1241 | /* TCP/UDP checksum offload engines. */ | |
1246 | mue_sethwcsum_locked(un); | 1242 | mue_sethwcsum_locked(un); | |
1247 | 1243 | |||
1248 | /* Set MTU. */ | 1244 | /* Set MTU. */ | |
1249 | mue_setmtu_locked(un); | 1245 | mue_setmtu_locked(un); | |
1250 | 1246 | |||
1251 | return usbnet_init_rx_tx(un); | 1247 | return usbnet_init_rx_tx(un); | |
1252 | } | 1248 | } |
--- src/sys/dev/usb/if_udav.c 2022/03/03 05:55:01 1.93
+++ src/sys/dev/usb/if_udav.c 2022/03/03 05:55:19 1.94
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_udav.c,v 1.93 2022/03/03 05:55:01 riastradh Exp $ */ | 1 | /* $NetBSD: if_udav.c,v 1.94 2022/03/03 05:55:19 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.93 2022/03/03 05:55:01 riastradh Exp $"); | 48 | __KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.94 2022/03/03 05:55:19 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 */ | |
60 | static int udav_match(device_t, cfdata_t, void *); | 60 | static int udav_match(device_t, cfdata_t, void *); | |
61 | static void udav_attach(device_t, device_t, void *); | 61 | static 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 | |||
464 | static int | 464 | static int | |
465 | udav_uno_init(struct ifnet *ifp) | 465 | udav_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 | /* Cancel pending I/O and free all TX/RX buffers */ | |||
475 | if (ifp->if_flags & IFF_RUNNING) | |||
476 | usbnet_stop(un, ifp, 1); | |||
477 | ||||
478 | memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr)); | 474 | memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr)); | |
479 | udav_csr_write(un, UDAV_PAR, eaddr, ETHER_ADDR_LEN); | 475 | udav_csr_write(un, UDAV_PAR, eaddr, ETHER_ADDR_LEN); | |
480 | 476 | |||
481 | /* Initialize network control register */ | 477 | /* Initialize network control register */ | |
482 | /* Disable loopback */ | 478 | /* Disable loopback */ | |
483 | UDAV_CLRBIT(un, UDAV_NCR, UDAV_NCR_LBK0 | UDAV_NCR_LBK1); | 479 | UDAV_CLRBIT(un, UDAV_NCR, UDAV_NCR_LBK0 | UDAV_NCR_LBK1); | |
484 | 480 | |||
485 | /* Initialize RX control register */ | 481 | /* Initialize RX control register */ | |
486 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_DIS_LONG | UDAV_RCR_DIS_CRC); | 482 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_DIS_LONG | UDAV_RCR_DIS_CRC); | |
487 | 483 | |||
488 | /* If we want promiscuous mode, accept all physical frames. */ | 484 | /* If we want promiscuous mode, accept all physical frames. */ | |
489 | if (ifp->if_flags & IFF_PROMISC) | 485 | if (ifp->if_flags & IFF_PROMISC) | |
490 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC); | 486 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC); |
--- src/sys/dev/usb/if_ure.c 2022/03/03 05:55:01 1.53
+++ src/sys/dev/usb/if_ure.c 2022/03/03 05:55:19 1.54
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ure.c,v 1.53 2022/03/03 05:55:01 riastradh Exp $ */ | 1 | /* $NetBSD: if_ure.c,v 1.54 2022/03/03 05:55:19 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.53 2022/03/03 05:55:01 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.54 2022/03/03 05:55:19 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,30 +403,26 @@ ure_reset(struct usbnet *un) | @@ -403,30 +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 | |||
410 | static int | 410 | static int | |
411 | ure_uno_init(struct ifnet *ifp) | 411 | ure_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 | /* Cancel pending I/O. */ | |||
417 | if (ifp->if_flags & IFF_RUNNING) | |||
418 | usbnet_stop(un, ifp, 1); | |||
419 | ||||
420 | /* Set MAC address. */ | 416 | /* Set MAC address. */ | |
421 | memset(eaddr, 0, sizeof(eaddr)); | 417 | memset(eaddr, 0, sizeof(eaddr)); | |
422 | memcpy(eaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN); | 418 | memcpy(eaddr, CLLADDR(ifp->if_sadl), ETHER_ADDR_LEN); | |
423 | ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG); | 419 | ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_CONFIG); | |
424 | ure_write_mem(un, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES, | 420 | ure_write_mem(un, URE_PLA_IDR, URE_MCU_TYPE_PLA | URE_BYTE_EN_SIX_BYTES, | |
425 | eaddr, 8); | 421 | eaddr, 8); | |
426 | ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML); | 422 | ure_write_1(un, URE_PLA_CRWECR, URE_MCU_TYPE_PLA, URE_CRWECR_NORAML); | |
427 | 423 | |||
428 | /* Reset the packet filter. */ | 424 | /* Reset the packet filter. */ | |
429 | ure_write_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA, | 425 | ure_write_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA, | |
430 | ure_read_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA) & | 426 | ure_read_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA) & | |
431 | ~URE_FMC_FCR_MCU_EN); | 427 | ~URE_FMC_FCR_MCU_EN); | |
432 | ure_write_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA, | 428 | ure_write_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA, |
--- src/sys/dev/usb/if_urndis.c 2022/03/03 05:54:45 1.41
+++ src/sys/dev/usb/if_urndis.c 2022/03/03 05:55:19 1.42
@@ -1,37 +1,37 @@ | @@ -1,37 +1,37 @@ | |||
1 | /* $NetBSD: if_urndis.c,v 1.41 2022/03/03 05:54:45 riastradh Exp $ */ | 1 | /* $NetBSD: if_urndis.c,v 1.42 2022/03/03 05:55:19 riastradh 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.41 2022/03/03 05:54:45 riastradh Exp $"); | 24 | __KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.42 2022/03/03 05:55:19 riastradh 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> | |
@@ -849,29 +849,26 @@ urndis_watchdog(struct ifnet *ifp) | @@ -849,29 +849,26 @@ urndis_watchdog(struct ifnet *ifp) | |||
849 | 849 | |||
850 | if_statinc(ifp, if_oerrors); | 850 | if_statinc(ifp, if_oerrors); | |
851 | printf("%s: watchdog timeout\n", DEVNAME(un)); | 851 | printf("%s: watchdog timeout\n", DEVNAME(un)); | |
852 | 852 | |||
853 | urndis_ctrl_keepalive(un); | 853 | urndis_ctrl_keepalive(un); | |
854 | } | 854 | } | |
855 | #endif | 855 | #endif | |
856 | 856 | |||
857 | static int | 857 | static int | |
858 | urndis_init_un(struct ifnet *ifp, struct usbnet *un) | 858 | urndis_init_un(struct ifnet *ifp, struct usbnet *un) | |
859 | { | 859 | { | |
860 | int err; | 860 | int err; | |
861 | 861 | |||
862 | if (ifp->if_flags & IFF_RUNNING) | |||
863 | return 0; | |||
864 | ||||
865 | err = urndis_ctrl_init(un); | 862 | err = urndis_ctrl_init(un); | |
866 | if (err != RNDIS_STATUS_SUCCESS) | 863 | if (err != RNDIS_STATUS_SUCCESS) | |
867 | return EIO; | 864 | return EIO; | |
868 | 865 | |||
869 | return err; | 866 | return err; | |
870 | } | 867 | } | |
871 | 868 | |||
872 | static int | 869 | static int | |
873 | urndis_uno_init(struct ifnet *ifp) | 870 | urndis_uno_init(struct ifnet *ifp) | |
874 | { | 871 | { | |
875 | struct usbnet *un = ifp->if_softc; | 872 | struct usbnet *un = ifp->if_softc; | |
876 | int error; | 873 | int error; | |
877 | 874 |