usbnet: Enter uno_init with the core lock held. This reduces code in all drivers except urndis(4) and aue(4). However, it's still safe for urndis to drop the core lock because the ifnet is locked, and the ifnet lock covers the DOWN->UP (uno_init) and UP->DOWN (uno_stop) transitions.diff -r1.171 -r1.172 src/sys/dev/usb/if_aue.c
(riastradh)
--- src/sys/dev/usb/if_aue.c 2020/03/18 11:33:32 1.171
+++ src/sys/dev/usb/if_aue.c 2022/03/03 05:50:22 1.172
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_aue.c,v 1.171 2020/03/18 11:33:32 kre Exp $ */ | 1 | /* $NetBSD: if_aue.c,v 1.172 2022/03/03 05:50:22 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.171 2020/03/18 11:33:32 kre Exp $"); | 79 | __KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.172 2022/03/03 05:50:22 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 | |
@@ -990,48 +990,49 @@ aue_init_locked(struct ifnet *ifp) | @@ -990,48 +990,49 @@ aue_init_locked(struct ifnet *ifp) | |||
990 | AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR); | 990 | AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR); | |
991 | 991 | |||
992 | //mii_mediachg(mii); | 992 | //mii_mediachg(mii); | |
993 | 993 | |||
994 | return rv; | 994 | return rv; | |
995 | } | 995 | } | |
996 | 996 | |||
997 | static int | 997 | static int | |
998 | aue_uno_init(struct ifnet *ifp) | 998 | aue_uno_init(struct ifnet *ifp) | |
999 | { | 999 | { | |
1000 | struct usbnet * const un = ifp->if_softc; | 1000 | struct usbnet * const un = ifp->if_softc; | |
1001 | int rv; | 1001 | int rv; | |
1002 | 1002 | |||
1003 | usbnet_lock_core(un); | |||
1004 | usbnet_busy(un); | 1003 | usbnet_busy(un); | |
1005 | rv = aue_init_locked(ifp); | 1004 | rv = aue_init_locked(ifp); | |
1006 | usbnet_unbusy(un); | 1005 | usbnet_unbusy(un); | |
1007 | usbnet_unlock_core(un); | |||
1008 | 1006 | |||
1009 | return rv; | 1007 | return rv; | |
1010 | } | 1008 | } | |
1011 | 1009 | |||
1012 | static int | 1010 | static int | |
1013 | aue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 1011 | aue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
1014 | { | 1012 | { | |
1013 | struct usbnet * const un = ifp->if_softc; | |||
1015 | 1014 | |||
1016 | AUEHIST_FUNC(); | 1015 | AUEHIST_FUNC(); | |
1017 | AUEHIST_CALLARGSN(5, "aue%jd: enter cmd %#jx data %#jx", | 1016 | AUEHIST_CALLARGSN(5, "aue%jd: enter cmd %#jx data %#jx", | |
1018 | device_unit(((struct usbnet *)(ifp->if_softc))->un_dev), | 1017 | device_unit(((struct usbnet *)(ifp->if_softc))->un_dev), | |
1019 | cmd, (uintptr_t)data, 0); | 1018 | cmd, (uintptr_t)data, 0); | |
1020 | 1019 | |||
1021 | switch (cmd) { | 1020 | switch (cmd) { | |
1022 | case SIOCADDMULTI: | 1021 | case SIOCADDMULTI: | |
1023 | case SIOCDELMULTI: | 1022 | case SIOCDELMULTI: | |
1023 | usbnet_lock_core(un); | |||
1024 | aue_uno_init(ifp); | 1024 | aue_uno_init(ifp); | |
1025 | usbnet_unlock_core(un); | |||
1025 | break; | 1026 | break; | |
1026 | default: | 1027 | default: | |
1027 | break; | 1028 | break; | |
1028 | } | 1029 | } | |
1029 | 1030 | |||
1030 | return 0; | 1031 | return 0; | |
1031 | } | 1032 | } | |
1032 | 1033 | |||
1033 | static void | 1034 | static void | |
1034 | aue_uno_stop(struct ifnet *ifp, int disable) | 1035 | aue_uno_stop(struct ifnet *ifp, int disable) | |
1035 | { | 1036 | { | |
1036 | struct usbnet * const un = ifp->if_softc; | 1037 | struct usbnet * const un = ifp->if_softc; | |
1037 | struct aue_softc * const sc = usbnet_softc(un); | 1038 | struct aue_softc * const sc = usbnet_softc(un); |
--- src/sys/dev/usb/if_axe.c 2021/03/01 17:41:00 1.132
+++ src/sys/dev/usb/if_axe.c 2022/03/03 05:50:22 1.133
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_axe.c,v 1.132 2021/03/01 17:41:00 jakllsch Exp $ */ | 1 | /* $NetBSD: if_axe.c,v 1.133 2022/03/03 05:50:22 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.132 2021/03/01 17:41:00 jakllsch Exp $"); | 90 | __KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.133 2022/03/03 05:50:22 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 | |||
103 | struct axe_type { | 103 | struct axe_type { | |
@@ -1307,31 +1307,29 @@ axe_init_locked(struct ifnet *ifp) | @@ -1307,31 +1307,29 @@ axe_init_locked(struct ifnet *ifp) | |||
1307 | axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL); | 1307 | axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL); | |
1308 | 1308 | |||
1309 | /* Accept multicast frame or run promisc. mode */ | 1309 | /* Accept multicast frame or run promisc. mode */ | |
1310 | axe_rcvfilt_locked(un); | 1310 | axe_rcvfilt_locked(un); | |
1311 | 1311 | |||
1312 | return usbnet_init_rx_tx(un); | 1312 | return usbnet_init_rx_tx(un); | |
1313 | } | 1313 | } | |
1314 | 1314 | |||
1315 | static int | 1315 | static int | |
1316 | axe_uno_init(struct ifnet *ifp) | 1316 | axe_uno_init(struct ifnet *ifp) | |
1317 | { | 1317 | { | |
1318 | struct usbnet * const un = ifp->if_softc; | 1318 | struct usbnet * const un = ifp->if_softc; | |
1319 | 1319 | |||
1320 | usbnet_lock_core(un); | |||
1321 | usbnet_busy(un); | 1320 | usbnet_busy(un); | |
1322 | int ret = axe_init_locked(ifp); | 1321 | int ret = axe_init_locked(ifp); | |
1323 | usbnet_unbusy(un); | 1322 | usbnet_unbusy(un); | |
1324 | usbnet_unlock_core(un); | |||
1325 | 1323 | |||
1326 | return ret; | 1324 | return ret; | |
1327 | } | 1325 | } | |
1328 | 1326 | |||
1329 | static int | 1327 | static int | |
1330 | axe_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 1328 | axe_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
1331 | { | 1329 | { | |
1332 | struct usbnet * const un = ifp->if_softc; | 1330 | struct usbnet * const un = ifp->if_softc; | |
1333 | 1331 | |||
1334 | usbnet_lock_core(un); | 1332 | usbnet_lock_core(un); | |
1335 | usbnet_busy(un); | 1333 | usbnet_busy(un); | |
1336 | 1334 | |||
1337 | switch (cmd) { | 1335 | switch (cmd) { |
--- src/sys/dev/usb/if_axen.c 2022/03/03 05:48:06 1.74
+++ src/sys/dev/usb/if_axen.c 2022/03/03 05:50:22 1.75
@@ -1,39 +1,39 @@ | @@ -1,39 +1,39 @@ | |||
1 | /* $NetBSD: if_axen.c,v 1.74 2022/03/03 05:48:06 riastradh Exp $ */ | 1 | /* $NetBSD: if_axen.c,v 1.75 2022/03/03 05:50:22 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.74 2022/03/03 05:48:06 riastradh Exp $"); | 26 | __KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.75 2022/03/03 05:50:22 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> | |
@@ -925,31 +925,29 @@ axen_init_locked(struct ifnet *ifp) | @@ -925,31 +925,29 @@ axen_init_locked(struct ifnet *ifp) | |||
925 | rxmode = le16toh(wval); | 925 | rxmode = le16toh(wval); | |
926 | rxmode |= AXEN_RXCTL_START; | 926 | rxmode |= AXEN_RXCTL_START; | |
927 | wval = htole16(rxmode); | 927 | wval = htole16(rxmode); | |
928 | axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); | 928 | axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); | |
929 | 929 | |||
930 | return usbnet_init_rx_tx(un); | 930 | return usbnet_init_rx_tx(un); | |
931 | } | 931 | } | |
932 | 932 | |||
933 | static int | 933 | static int | |
934 | axen_uno_init(struct ifnet *ifp) | 934 | axen_uno_init(struct ifnet *ifp) | |
935 | { | 935 | { | |
936 | struct usbnet * const un = ifp->if_softc; | 936 | struct usbnet * const un = ifp->if_softc; | |
937 | 937 | |||
938 | usbnet_lock_core(un); | |||
939 | usbnet_busy(un); | 938 | usbnet_busy(un); | |
940 | int ret = axen_init_locked(ifp); | 939 | int ret = axen_init_locked(ifp); | |
941 | usbnet_unbusy(un); | 940 | usbnet_unbusy(un); | |
942 | usbnet_unlock_core(un); | |||
943 | 941 | |||
944 | return ret; | 942 | return ret; | |
945 | } | 943 | } | |
946 | 944 | |||
947 | static void | 945 | static void | |
948 | axen_uno_stop(struct ifnet *ifp, int disable) | 946 | axen_uno_stop(struct ifnet *ifp, int disable) | |
949 | { | 947 | { | |
950 | struct usbnet * const un = ifp->if_softc; | 948 | struct usbnet * const un = ifp->if_softc; | |
951 | uint16_t rxmode, wval; | 949 | uint16_t rxmode, wval; | |
952 | 950 | |||
953 | axen_reset(un); | 951 | axen_reset(un); | |
954 | 952 | |||
955 | /* Disable receiver, set RX mode */ | 953 | /* Disable receiver, set RX mode */ |
--- src/sys/dev/usb/if_cdce.c 2020/05/15 19:28:10 1.72
+++ src/sys/dev/usb/if_cdce.c 2022/03/03 05:50:22 1.73
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_cdce.c,v 1.72 2020/05/15 19:28:10 maxv Exp $ */ | 1 | /* $NetBSD: if_cdce.c,v 1.73 2022/03/03 05:50:22 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.72 2020/05/15 19:28:10 maxv Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.73 2022/03/03 05:50:22 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 | |||
52 | struct cdce_type { | 52 | struct 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,35 +251,33 @@ cdce_attach(device_t parent, device_t se | @@ -251,35 +251,33 @@ 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 | |||
258 | static int | 258 | static int | |
259 | cdce_uno_init(struct ifnet *ifp) | 259 | cdce_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 | usbnet_lock_core(un); | |||
265 | if (usbnet_isdying(un)) | 264 | if (usbnet_isdying(un)) | |
266 | rv = EIO; | 265 | rv = EIO; | |
267 | else { | 266 | else { | |
268 | usbnet_stop(un, ifp, 1); | 267 | usbnet_stop(un, ifp, 1); | |
269 | rv = usbnet_init_rx_tx(un); | 268 | rv = usbnet_init_rx_tx(un); | |
270 | usbnet_set_link(un, rv == 0); | 269 | usbnet_set_link(un, rv == 0); | |
271 | } | 270 | } | |
272 | usbnet_unlock_core(un); | |||
273 | 271 | |||
274 | return rv; | 272 | return rv; | |
275 | } | 273 | } | |
276 | 274 | |||
277 | static void | 275 | static void | |
278 | cdce_uno_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len) | 276 | cdce_uno_rx_loop(struct usbnet * un, struct usbnet_chain *c, uint32_t total_len) | |
279 | { | 277 | { | |
280 | struct ifnet *ifp = usbnet_ifp(un); | 278 | struct ifnet *ifp = usbnet_ifp(un); | |
281 | 279 | |||
282 | usbnet_isowned_rx(un); | 280 | usbnet_isowned_rx(un); | |
283 | 281 | |||
284 | /* Strip off CRC added by Zaurus, if present */ | 282 | /* Strip off CRC added by Zaurus, if present */ | |
285 | if (un->un_flags & CDCE_ZAURUS && total_len > 4) | 283 | if (un->un_flags & CDCE_ZAURUS && total_len > 4) |
--- src/sys/dev/usb/if_cue.c 2022/03/03 05:49:51 1.92
+++ src/sys/dev/usb/if_cue.c 2022/03/03 05:50:22 1.93
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_cue.c,v 1.92 2022/03/03 05:49:51 riastradh Exp $ */ | 1 | /* $NetBSD: if_cue.c,v 1.93 2022/03/03 05:50:22 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.92 2022/03/03 05:49:51 riastradh Exp $"); | 60 | __KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.93 2022/03/03 05:50:22 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> | |
@@ -663,31 +663,29 @@ cue_init_locked(struct ifnet *ifp) | @@ -663,31 +663,29 @@ cue_init_locked(struct ifnet *ifp) | |||
663 | 663 | |||
664 | /* Program the LED operation. */ | 664 | /* Program the LED operation. */ | |
665 | cue_csr_write_1(un, CUE_LEDCTL, CUE_LEDCTL_FOLLOW_LINK); | 665 | cue_csr_write_1(un, CUE_LEDCTL, CUE_LEDCTL_FOLLOW_LINK); | |
666 | 666 | |||
667 | return usbnet_init_rx_tx(un); | 667 | return usbnet_init_rx_tx(un); | |
668 | } | 668 | } | |
669 | 669 | |||
670 | static int | 670 | static int | |
671 | cue_uno_init(struct ifnet *ifp) | 671 | cue_uno_init(struct ifnet *ifp) | |
672 | { | 672 | { | |
673 | struct usbnet * const un = ifp->if_softc; | 673 | struct usbnet * const un = ifp->if_softc; | |
674 | int rv; | 674 | int rv; | |
675 | 675 | |||
676 | usbnet_lock_core(un); | |||
677 | usbnet_busy(un); | 676 | usbnet_busy(un); | |
678 | rv = cue_init_locked(ifp); | 677 | rv = cue_init_locked(ifp); | |
679 | usbnet_unbusy(un); | 678 | usbnet_unbusy(un); | |
680 | usbnet_unlock_core(un); | |||
681 | 679 | |||
682 | return rv; | 680 | return rv; | |
683 | } | 681 | } | |
684 | 682 | |||
685 | static int | 683 | static int | |
686 | cue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 684 | cue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
687 | { | 685 | { | |
688 | struct usbnet * const un = ifp->if_softc; | 686 | struct usbnet * const un = ifp->if_softc; | |
689 | 687 | |||
690 | usbnet_lock_core(un); | 688 | usbnet_lock_core(un); | |
691 | usbnet_busy(un); | 689 | usbnet_busy(un); | |
692 | 690 | |||
693 | switch (cmd) { | 691 | switch (cmd) { |
--- src/sys/dev/usb/if_kue.c 2021/06/13 09:26:24 1.105
+++ src/sys/dev/usb/if_kue.c 2022/03/03 05:50:22 1.106
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_kue.c,v 1.105 2021/06/13 09:26:24 mlelstv Exp $ */ | 1 | /* $NetBSD: if_kue.c,v 1.106 2022/03/03 05:50:22 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.105 2021/06/13 09:26:24 mlelstv Exp $"); | 74 | __KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.106 2022/03/03 05:50:22 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> | |
@@ -623,31 +623,29 @@ kue_init_locked(struct ifnet *ifp) | @@ -623,31 +623,29 @@ kue_init_locked(struct ifnet *ifp) | |||
623 | 623 | |||
624 | /* Load the multicast filter. */ | 624 | /* Load the multicast filter. */ | |
625 | kue_setiff_locked(un); | 625 | kue_setiff_locked(un); | |
626 | 626 | |||
627 | return usbnet_init_rx_tx(un); | 627 | return usbnet_init_rx_tx(un); | |
628 | } | 628 | } | |
629 | 629 | |||
630 | static int | 630 | static int | |
631 | kue_uno_init(struct ifnet *ifp) | 631 | kue_uno_init(struct ifnet *ifp) | |
632 | { | 632 | { | |
633 | struct usbnet * const un = ifp->if_softc; | 633 | struct usbnet * const un = ifp->if_softc; | |
634 | int rv; | 634 | int rv; | |
635 | 635 | |||
636 | usbnet_lock_core(un); | |||
637 | usbnet_busy(un); | 636 | usbnet_busy(un); | |
638 | rv = kue_init_locked(ifp); | 637 | rv = kue_init_locked(ifp); | |
639 | usbnet_unbusy(un); | 638 | usbnet_unbusy(un); | |
640 | usbnet_unlock_core(un); | |||
641 | 639 | |||
642 | return rv; | 640 | return rv; | |
643 | } | 641 | } | |
644 | 642 | |||
645 | static int | 643 | static int | |
646 | kue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 644 | kue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
647 | { | 645 | { | |
648 | struct usbnet * const un = ifp->if_softc; | 646 | struct usbnet * const un = ifp->if_softc; | |
649 | 647 | |||
650 | usbnet_lock_core(un); | 648 | usbnet_lock_core(un); | |
651 | usbnet_busy(un); | 649 | usbnet_busy(un); | |
652 | 650 | |||
653 | switch (cmd) { | 651 | switch (cmd) { |
--- src/sys/dev/usb/if_mos.c 2020/04/02 04:09:36 1.7
+++ src/sys/dev/usb/if_mos.c 2022/03/03 05:50:22 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_mos.c,v 1.7 2020/04/02 04:09:36 nisimura Exp $ */ | 1 | /* $NetBSD: if_mos.c,v 1.8 2022/03/03 05:50:22 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.7 2020/04/02 04:09:36 nisimura Exp $"); | 75 | __KERNEL_RCSID(0, "$NetBSD: if_mos.c,v 1.8 2022/03/03 05:50:22 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 | |||
@@ -750,31 +750,29 @@ mos_init_locked(struct ifnet *ifp) | @@ -750,31 +750,29 @@ mos_init_locked(struct ifnet *ifp) | |||
750 | rxmode = mos_reg_read_1(un, MOS_CTL); | 750 | rxmode = mos_reg_read_1(un, MOS_CTL); | |
751 | rxmode |= MOS_CTL_RX_ENB | MOS_CTL_TX_ENB | MOS_CTL_BS_ENB; | 751 | rxmode |= MOS_CTL_RX_ENB | MOS_CTL_TX_ENB | MOS_CTL_BS_ENB; | |
752 | rxmode &= ~(MOS_CTL_SLEEP); | 752 | rxmode &= ~(MOS_CTL_SLEEP); | |
753 | mos_reg_write_1(un, MOS_CTL, rxmode); | 753 | mos_reg_write_1(un, MOS_CTL, rxmode); | |
754 | 754 | |||
755 | return usbnet_init_rx_tx(un); | 755 | return usbnet_init_rx_tx(un); | |
756 | } | 756 | } | |
757 | 757 | |||
758 | static int | 758 | static int | |
759 | mos_uno_init(struct ifnet *ifp) | 759 | mos_uno_init(struct ifnet *ifp) | |
760 | { | 760 | { | |
761 | struct usbnet * const un = ifp->if_softc; | 761 | struct usbnet * const un = ifp->if_softc; | |
762 | 762 | |||
763 | usbnet_lock_core(un); | |||
764 | usbnet_busy(un); | 763 | usbnet_busy(un); | |
765 | int ret = mos_init_locked(ifp); | 764 | int ret = mos_init_locked(ifp); | |
766 | usbnet_unbusy(un); | 765 | usbnet_unbusy(un); | |
767 | usbnet_unlock_core(un); | |||
768 | 766 | |||
769 | return ret; | 767 | return ret; | |
770 | } | 768 | } | |
771 | 769 | |||
772 | static int | 770 | static int | |
773 | mos_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 771 | mos_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
774 | { | 772 | { | |
775 | struct usbnet * const un = ifp->if_softc; | 773 | struct usbnet * const un = ifp->if_softc; | |
776 | 774 | |||
777 | usbnet_lock_core(un); | 775 | usbnet_lock_core(un); | |
778 | usbnet_busy(un); | 776 | usbnet_busy(un); | |
779 | 777 | |||
780 | switch (cmd) { | 778 | switch (cmd) { |
--- src/sys/dev/usb/if_mue.c 2022/03/03 05:48:06 1.63
+++ src/sys/dev/usb/if_mue.c 2022/03/03 05:50:22 1.64
@@ -1,36 +1,36 @@ | @@ -1,36 +1,36 @@ | |||
1 | /* $NetBSD: if_mue.c,v 1.63 2022/03/03 05:48:06 riastradh Exp $ */ | 1 | /* $NetBSD: if_mue.c,v 1.64 2022/03/03 05:50:22 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.63 2022/03/03 05:48:06 riastradh Exp $"); | 23 | __KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.64 2022/03/03 05:50:22 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 | |||
@@ -1245,31 +1245,29 @@ mue_init_locked(struct ifnet *ifp) | @@ -1245,31 +1245,29 @@ mue_init_locked(struct ifnet *ifp) | |||
1245 | 1245 | |||
1246 | /* Set MTU. */ | 1246 | /* Set MTU. */ | |
1247 | mue_setmtu_locked(un); | 1247 | mue_setmtu_locked(un); | |
1248 | 1248 | |||
1249 | return usbnet_init_rx_tx(un); | 1249 | return usbnet_init_rx_tx(un); | |
1250 | } | 1250 | } | |
1251 | 1251 | |||
1252 | static int | 1252 | static int | |
1253 | mue_uno_init(struct ifnet *ifp) | 1253 | mue_uno_init(struct ifnet *ifp) | |
1254 | { | 1254 | { | |
1255 | struct usbnet * const un = ifp->if_softc; | 1255 | struct usbnet * const un = ifp->if_softc; | |
1256 | int rv; | 1256 | int rv; | |
1257 | 1257 | |||
1258 | usbnet_lock_core(un); | |||
1259 | usbnet_busy(un); | 1258 | usbnet_busy(un); | |
1260 | rv = mue_init_locked(ifp); | 1259 | rv = mue_init_locked(ifp); | |
1261 | usbnet_unbusy(un); | 1260 | usbnet_unbusy(un); | |
1262 | usbnet_unlock_core(un); | |||
1263 | 1261 | |||
1264 | return rv; | 1262 | return rv; | |
1265 | } | 1263 | } | |
1266 | 1264 | |||
1267 | static int | 1265 | static int | |
1268 | mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 1266 | mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
1269 | { | 1267 | { | |
1270 | struct usbnet * const un = ifp->if_softc; | 1268 | struct usbnet * const un = ifp->if_softc; | |
1271 | 1269 | |||
1272 | usbnet_lock_core(un); | 1270 | usbnet_lock_core(un); | |
1273 | usbnet_busy(un); | 1271 | usbnet_busy(un); | |
1274 | 1272 | |||
1275 | switch (cmd) { | 1273 | switch (cmd) { |
--- src/sys/dev/usb/if_smsc.c 2022/03/03 05:48:06 1.71
+++ src/sys/dev/usb/if_smsc.c 2022/03/03 05:50:22 1.72
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_smsc.c,v 1.71 2022/03/03 05:48:06 riastradh Exp $ */ | 1 | /* $NetBSD: if_smsc.c,v 1.72 2022/03/03 05:50:22 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.71 2022/03/03 05:48:06 riastradh Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.72 2022/03/03 05:50:22 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" | |
@@ -542,31 +542,29 @@ smsc_reset(struct smsc_softc *sc) | @@ -542,31 +542,29 @@ smsc_reset(struct smsc_softc *sc) | |||
542 | 542 | |||
543 | /* Wait a little while for the chip to get its brains in order. */ | 543 | /* Wait a little while for the chip to get its brains in order. */ | |
544 | DELAY(1000); | 544 | DELAY(1000); | |
545 | 545 | |||
546 | /* Reinitialize controller to achieve full reset. */ | 546 | /* Reinitialize controller to achieve full reset. */ | |
547 | smsc_chip_init(un); | 547 | smsc_chip_init(un); | |
548 | } | 548 | } | |
549 | 549 | |||
550 | static int | 550 | static int | |
551 | smsc_uno_init(struct ifnet *ifp) | 551 | smsc_uno_init(struct ifnet *ifp) | |
552 | { | 552 | { | |
553 | struct usbnet * const un = ifp->if_softc; | 553 | struct usbnet * const un = ifp->if_softc; | |
554 | 554 | |||
555 | usbnet_lock_core(un); | |||
556 | usbnet_busy(un); | 555 | usbnet_busy(un); | |
557 | int ret = smsc_init_locked(ifp); | 556 | int ret = smsc_init_locked(ifp); | |
558 | usbnet_unbusy(un); | 557 | usbnet_unbusy(un); | |
559 | usbnet_unlock_core(un); | |||
560 | 558 | |||
561 | return ret; | 559 | return ret; | |
562 | } | 560 | } | |
563 | 561 | |||
564 | static int | 562 | static int | |
565 | smsc_init_locked(struct ifnet *ifp) | 563 | smsc_init_locked(struct ifnet *ifp) | |
566 | { | 564 | { | |
567 | struct usbnet * const un = ifp->if_softc; | 565 | struct usbnet * const un = ifp->if_softc; | |
568 | struct smsc_softc * const sc = usbnet_softc(un); | 566 | struct smsc_softc * const sc = usbnet_softc(un); | |
569 | 567 | |||
570 | usbnet_isowned_core(un); | 568 | usbnet_isowned_core(un); | |
571 | 569 | |||
572 | if (usbnet_isdying(un)) | 570 | if (usbnet_isdying(un)) |
--- src/sys/dev/usb/if_upl.c 2020/03/15 23:04:51 1.71
+++ src/sys/dev/usb/if_upl.c 2022/03/03 05:50:22 1.72
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_upl.c,v 1.71 2020/03/15 23:04:51 thorpej Exp $ */ | 1 | /* $NetBSD: if_upl.c,v 1.72 2022/03/03 05:50:22 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.71 2020/03/15 23:04:51 thorpej Exp $"); | 38 | __KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.72 2022/03/03 05:50:22 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,32 +247,30 @@ upl_uno_tx_prepare(struct usbnet *un, st | @@ -247,32 +247,30 @@ 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 | |||
254 | static int | 254 | static int | |
255 | upl_uno_init(struct ifnet *ifp) | 255 | upl_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 | usbnet_lock_core(un); | |||
261 | if (usbnet_isdying(un)) | 260 | if (usbnet_isdying(un)) | |
262 | rv = EIO; | 261 | rv = EIO; | |
263 | else | 262 | else | |
264 | rv = usbnet_init_rx_tx(un); | 263 | rv = usbnet_init_rx_tx(un); | |
265 | usbnet_unlock_core(un); | |||
266 | 264 | |||
267 | return rv; | 265 | return rv; | |
268 | } | 266 | } | |
269 | 267 | |||
270 | static int | 268 | static int | |
271 | upl_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 269 | upl_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
272 | { | 270 | { | |
273 | if (cmd == SIOCSIFMTU) { | 271 | if (cmd == SIOCSIFMTU) { | |
274 | struct ifreq *ifr = data; | 272 | struct ifreq *ifr = data; | |
275 | 273 | |||
276 | if (ifr->ifr_mtu > UPL_BUFSZ) | 274 | if (ifr->ifr_mtu > UPL_BUFSZ) | |
277 | return EINVAL; | 275 | return EINVAL; | |
278 | } | 276 | } |
--- src/sys/dev/usb/if_udav.c 2021/04/02 09:27:44 1.78
+++ src/sys/dev/usb/if_udav.c 2022/03/03 05:50:22 1.79
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_udav.c,v 1.78 2021/04/02 09:27:44 skrll Exp $ */ | 1 | /* $NetBSD: if_udav.c,v 1.79 2022/03/03 05:50:22 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.78 2021/04/02 09:27:44 skrll Exp $"); | 48 | __KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.79 2022/03/03 05:50:22 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 *); | |
@@ -468,30 +468,27 @@ udav_csr_write1(struct usbnet *un, int o | @@ -468,30 +468,27 @@ udav_csr_write1(struct usbnet *un, int o | |||
468 | return err; | 468 | return err; | |
469 | } | 469 | } | |
470 | 470 | |||
471 | static int | 471 | static int | |
472 | udav_uno_init(struct ifnet *ifp) | 472 | udav_uno_init(struct ifnet *ifp) | |
473 | { | 473 | { | |
474 | struct usbnet * const un = ifp->if_softc; | 474 | struct usbnet * const un = ifp->if_softc; | |
475 | struct mii_data * const mii = usbnet_mii(un); | 475 | struct mii_data * const mii = usbnet_mii(un); | |
476 | uint8_t eaddr[ETHER_ADDR_LEN]; | 476 | uint8_t eaddr[ETHER_ADDR_LEN]; | |
477 | int rc = 0; | 477 | int rc = 0; | |
478 | 478 | |||
479 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | 479 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | |
480 | 480 | |||
481 | usbnet_lock_core(un); | |||
482 | ||||
483 | if (usbnet_isdying(un)) { | 481 | if (usbnet_isdying(un)) { | |
484 | usbnet_unlock_core(un); | |||
485 | return EIO; | 482 | return EIO; | |
486 | } | 483 | } | |
487 | 484 | |||
488 | /* Cancel pending I/O and free all TX/RX buffers */ | 485 | /* Cancel pending I/O and free all TX/RX buffers */ | |
489 | if (ifp->if_flags & IFF_RUNNING) | 486 | if (ifp->if_flags & IFF_RUNNING) | |
490 | usbnet_stop(un, ifp, 1); | 487 | usbnet_stop(un, ifp, 1); | |
491 | 488 | |||
492 | usbnet_busy(un); | 489 | usbnet_busy(un); | |
493 | 490 | |||
494 | memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr)); | 491 | memcpy(eaddr, CLLADDR(ifp->if_sadl), sizeof(eaddr)); | |
495 | udav_csr_write(un, UDAV_PAR, eaddr, ETHER_ADDR_LEN); | 492 | udav_csr_write(un, UDAV_PAR, eaddr, ETHER_ADDR_LEN); | |
496 | 493 | |||
497 | /* Initialize network control register */ | 494 | /* Initialize network control register */ | |
@@ -512,37 +509,35 @@ udav_uno_init(struct ifnet *ifp) | @@ -512,37 +509,35 @@ udav_uno_init(struct ifnet *ifp) | |||
512 | 509 | |||
513 | /* Enable RX */ | 510 | /* Enable RX */ | |
514 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_RXEN); | 511 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_RXEN); | |
515 | 512 | |||
516 | /* clear POWER_DOWN state of internal PHY */ | 513 | /* clear POWER_DOWN state of internal PHY */ | |
517 | UDAV_SETBIT(un, UDAV_GPCR, UDAV_GPCR_GEP_CNTL0); | 514 | UDAV_SETBIT(un, UDAV_GPCR, UDAV_GPCR_GEP_CNTL0); | |
518 | UDAV_CLRBIT(un, UDAV_GPR, UDAV_GPR_GEPIO0); | 515 | UDAV_CLRBIT(un, UDAV_GPR, UDAV_GPR_GEPIO0); | |
519 | 516 | |||
520 | if (mii && (rc = mii_mediachg(mii)) == ENXIO) | 517 | if (mii && (rc = mii_mediachg(mii)) == ENXIO) | |
521 | rc = 0; | 518 | rc = 0; | |
522 | 519 | |||
523 | if (rc != 0) { | 520 | if (rc != 0) { | |
524 | usbnet_unbusy(un); | 521 | usbnet_unbusy(un); | |
525 | usbnet_unlock_core(un); | |||
526 | return rc; | 522 | return rc; | |
527 | } | 523 | } | |
528 | 524 | |||
529 | if (usbnet_isdying(un)) | 525 | if (usbnet_isdying(un)) | |
530 | rc = EIO; | 526 | rc = EIO; | |
531 | else | 527 | else | |
532 | rc = usbnet_init_rx_tx(un); | 528 | rc = usbnet_init_rx_tx(un); | |
533 | 529 | |||
534 | usbnet_unbusy(un); | 530 | usbnet_unbusy(un); | |
535 | usbnet_unlock_core(un); | |||
536 | 531 | |||
537 | return rc; | 532 | return rc; | |
538 | } | 533 | } | |
539 | 534 | |||
540 | static void | 535 | static void | |
541 | udav_reset(struct usbnet *un) | 536 | udav_reset(struct usbnet *un) | |
542 | { | 537 | { | |
543 | usbnet_isowned_core(un); | 538 | usbnet_isowned_core(un); | |
544 | 539 | |||
545 | if (usbnet_isdying(un)) | 540 | if (usbnet_isdying(un)) | |
546 | return; | 541 | return; | |
547 | 542 | |||
548 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | 543 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); |
--- src/sys/dev/usb/if_url.c 2022/03/03 05:48:14 1.78
+++ src/sys/dev/usb/if_url.c 2022/03/03 05:50:22 1.79
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_url.c,v 1.78 2022/03/03 05:48:14 riastradh Exp $ */ | 1 | /* $NetBSD: if_url.c,v 1.79 2022/03/03 05:50:22 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.78 2022/03/03 05:48:14 riastradh Exp $"); | 47 | __KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.79 2022/03/03 05:50:22 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 | |
@@ -398,31 +398,29 @@ url_init_locked(struct ifnet *ifp) | @@ -398,31 +398,29 @@ url_init_locked(struct ifnet *ifp) | |||
398 | url_rcvfilt_locked(un); | 398 | url_rcvfilt_locked(un); | |
399 | 399 | |||
400 | /* Enable RX and TX */ | 400 | /* Enable RX and TX */ | |
401 | URL_SETBIT(un, URL_CR, URL_CR_TE | URL_CR_RE); | 401 | URL_SETBIT(un, URL_CR, URL_CR_TE | URL_CR_RE); | |
402 | 402 | |||
403 | return usbnet_init_rx_tx(un); | 403 | return usbnet_init_rx_tx(un); | |
404 | } | 404 | } | |
405 | 405 | |||
406 | static int | 406 | static int | |
407 | url_uno_init(struct ifnet *ifp) | 407 | url_uno_init(struct ifnet *ifp) | |
408 | { | 408 | { | |
409 | struct usbnet * const un = ifp->if_softc; | 409 | struct usbnet * const un = ifp->if_softc; | |
410 | 410 | |||
411 | usbnet_lock_core(un); | |||
412 | usbnet_busy(un); | 411 | usbnet_busy(un); | |
413 | int ret = url_init_locked(ifp); | 412 | int ret = url_init_locked(ifp); | |
414 | usbnet_unbusy(un); | 413 | usbnet_unbusy(un); | |
415 | usbnet_unlock_core(un); | |||
416 | 414 | |||
417 | return ret; | 415 | return ret; | |
418 | } | 416 | } | |
419 | 417 | |||
420 | static void | 418 | static void | |
421 | url_reset(struct usbnet *un) | 419 | url_reset(struct usbnet *un) | |
422 | { | 420 | { | |
423 | int i; | 421 | int i; | |
424 | 422 | |||
425 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | 423 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | |
426 | 424 | |||
427 | if (usbnet_isdying(un)) | 425 | if (usbnet_isdying(un)) | |
428 | return; | 426 | return; |
--- src/sys/dev/usb/if_ure.c 2020/03/27 18:04:45 1.40
+++ src/sys/dev/usb/if_ure.c 2022/03/03 05:50:22 1.41
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ure.c,v 1.40 2020/03/27 18:04:45 nisimura Exp $ */ | 1 | /* $NetBSD: if_ure.c,v 1.41 2022/03/03 05:50:22 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.40 2020/03/27 18:04:45 nisimura Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.41 2022/03/03 05:50:22 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 | |||
@@ -446,31 +446,29 @@ ure_init_locked(struct ifnet *ifp) | @@ -446,31 +446,29 @@ ure_init_locked(struct ifnet *ifp) | |||
446 | ~URE_RXDY_GATED_EN); | 446 | ~URE_RXDY_GATED_EN); | |
447 | 447 | |||
448 | /* Accept multicast frame or run promisc. mode. */ | 448 | /* Accept multicast frame or run promisc. mode. */ | |
449 | ure_rcvfilt_locked(un); | 449 | ure_rcvfilt_locked(un); | |
450 | 450 | |||
451 | return usbnet_init_rx_tx(un); | 451 | return usbnet_init_rx_tx(un); | |
452 | } | 452 | } | |
453 | 453 | |||
454 | static int | 454 | static int | |
455 | ure_uno_init(struct ifnet *ifp) | 455 | ure_uno_init(struct ifnet *ifp) | |
456 | { | 456 | { | |
457 | struct usbnet * const un = ifp->if_softc; | 457 | struct usbnet * const un = ifp->if_softc; | |
458 | 458 | |||
459 | usbnet_lock_core(un); | |||
460 | usbnet_busy(un); | 459 | usbnet_busy(un); | |
461 | int ret = ure_init_locked(ifp); | 460 | int ret = ure_init_locked(ifp); | |
462 | usbnet_unbusy(un); | 461 | usbnet_unbusy(un); | |
463 | usbnet_unlock_core(un); | |||
464 | 462 | |||
465 | return ret; | 463 | return ret; | |
466 | } | 464 | } | |
467 | 465 | |||
468 | static void | 466 | static void | |
469 | ure_uno_stop(struct ifnet *ifp, int disable __unused) | 467 | ure_uno_stop(struct ifnet *ifp, int disable __unused) | |
470 | { | 468 | { | |
471 | struct usbnet * const un = ifp->if_softc; | 469 | struct usbnet * const un = ifp->if_softc; | |
472 | 470 | |||
473 | ure_reset(un); | 471 | ure_reset(un); | |
474 | } | 472 | } | |
475 | 473 | |||
476 | static void | 474 | static void |
--- src/sys/dev/usb/if_urndis.c 2020/03/15 23:04:51 1.39
+++ src/sys/dev/usb/if_urndis.c 2022/03/03 05:50:22 1.40
@@ -1,37 +1,37 @@ | @@ -1,37 +1,37 @@ | |||
1 | /* $NetBSD: if_urndis.c,v 1.39 2020/03/15 23:04:51 thorpej Exp $ */ | 1 | /* $NetBSD: if_urndis.c,v 1.40 2022/03/03 05:50:22 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.39 2020/03/15 23:04:51 thorpej Exp $"); | 24 | __KERNEL_RCSID(0, "$NetBSD: if_urndis.c,v 1.40 2022/03/03 05:50:22 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> | |
@@ -873,28 +873,35 @@ urndis_init_un(struct ifnet *ifp, struct | @@ -873,28 +873,35 @@ urndis_init_un(struct ifnet *ifp, struct | |||
873 | usbnet_stop(un, ifp, 1); | 873 | usbnet_stop(un, ifp, 1); | |
874 | err = usbnet_init_rx_tx(un); | 874 | err = usbnet_init_rx_tx(un); | |
875 | usbnet_set_link(un, err == 0); | 875 | usbnet_set_link(un, err == 0); | |
876 | } | 876 | } | |
877 | usbnet_unlock_core(un); | 877 | usbnet_unlock_core(un); | |
878 | 878 | |||
879 | return err; | 879 | return err; | |
880 | } | 880 | } | |
881 | 881 | |||
882 | static int | 882 | static int | |
883 | urndis_uno_init(struct ifnet *ifp) | 883 | urndis_uno_init(struct ifnet *ifp) | |
884 | { | 884 | { | |
885 | struct usbnet *un = ifp->if_softc; | 885 | struct usbnet *un = ifp->if_softc; | |
886 | int error; | |||
886 | 887 | |||
887 | return urndis_init_un(ifp, un); | 888 | KASSERT(IFNET_LOCKED(ifp)); | |
889 | ||||
890 | usbnet_unlock_core(un); | |||
891 | error = urndis_init_un(ifp, un); | |||
892 | usbnet_lock_core(un); | |||
893 | ||||
894 | return error; | |||
888 | } | 895 | } | |
889 | 896 | |||
890 | static int | 897 | static int | |
891 | urndis_match(device_t parent, cfdata_t match, void *aux) | 898 | urndis_match(device_t parent, cfdata_t match, void *aux) | |
892 | { | 899 | { | |
893 | struct usbif_attach_arg *uiaa = aux; | 900 | struct usbif_attach_arg *uiaa = aux; | |
894 | usb_interface_descriptor_t *id; | 901 | usb_interface_descriptor_t *id; | |
895 | 902 | |||
896 | if (!uiaa->uiaa_iface) | 903 | if (!uiaa->uiaa_iface) | |
897 | return UMATCH_NONE; | 904 | return UMATCH_NONE; | |
898 | 905 | |||
899 | id = usbd_get_interface_descriptor(uiaa->uiaa_iface); | 906 | id = usbd_get_interface_descriptor(uiaa->uiaa_iface); | |
900 | if (id == NULL) | 907 | if (id == NULL) |
--- src/sys/dev/usb/usbnet.c 2022/03/03 05:50:12 1.70
+++ src/sys/dev/usb/usbnet.c 2022/03/03 05:50:22 1.71
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: usbnet.c,v 1.70 2022/03/03 05:50:12 riastradh Exp $ */ | 1 | /* $NetBSD: usbnet.c,v 1.71 2022/03/03 05:50:22 riastradh 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. | |
@@ -21,27 +21,27 @@ | @@ -21,27 +21,27 @@ | |||
21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | |
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | /* | 29 | /* | |
30 | * Common code shared between USB network drivers. | 30 | * Common code shared between USB network drivers. | |
31 | */ | 31 | */ | |
32 | 32 | |||
33 | #include <sys/cdefs.h> | 33 | #include <sys/cdefs.h> | |
34 | __KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.70 2022/03/03 05:50:12 riastradh Exp $"); | 34 | __KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.71 2022/03/03 05:50:22 riastradh Exp $"); | |
35 | 35 | |||
36 | #include <sys/param.h> | 36 | #include <sys/param.h> | |
37 | #include <sys/kernel.h> | 37 | #include <sys/kernel.h> | |
38 | #include <sys/kmem.h> | 38 | #include <sys/kmem.h> | |
39 | #include <sys/module.h> | 39 | #include <sys/module.h> | |
40 | #include <sys/atomic.h> | 40 | #include <sys/atomic.h> | |
41 | 41 | |||
42 | #include <dev/usb/usbnet.h> | 42 | #include <dev/usb/usbnet.h> | |
43 | #include <dev/usb/usbhist.h> | 43 | #include <dev/usb/usbhist.h> | |
44 | 44 | |||
45 | struct usbnet_cdata { | 45 | struct usbnet_cdata { | |
46 | struct usbnet_chain *uncd_tx_chain; | 46 | struct usbnet_chain *uncd_tx_chain; | |
47 | struct usbnet_chain *uncd_rx_chain; | 47 | struct usbnet_chain *uncd_rx_chain; | |
@@ -1281,40 +1281,45 @@ usbnet_tick_task(void *arg) | @@ -1281,40 +1281,45 @@ usbnet_tick_task(void *arg) | |||
1281 | 1281 | |||
1282 | mutex_enter(&unp->unp_core_lock); | 1282 | mutex_enter(&unp->unp_core_lock); | |
1283 | if (!unp->unp_stopping && !unp->unp_dying) | 1283 | if (!unp->unp_stopping && !unp->unp_dying) | |
1284 | callout_schedule(&unp->unp_stat_ch, hz); | 1284 | callout_schedule(&unp->unp_stat_ch, hz); | |
1285 | mutex_exit(&unp->unp_core_lock); | 1285 | mutex_exit(&unp->unp_core_lock); | |
1286 | } | 1286 | } | |
1287 | 1287 | |||
1288 | static int | 1288 | static int | |
1289 | usbnet_if_init(struct ifnet *ifp) | 1289 | usbnet_if_init(struct ifnet *ifp) | |
1290 | { | 1290 | { | |
1291 | USBNETHIST_FUNC(); USBNETHIST_CALLED(); | 1291 | USBNETHIST_FUNC(); USBNETHIST_CALLED(); | |
1292 | struct usbnet * const un = ifp->if_softc; | 1292 | struct usbnet * const un = ifp->if_softc; | |
1293 | bool dying; | 1293 | bool dying; | |
1294 | int error; | |||
1294 | 1295 | |||
1295 | KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname); | 1296 | KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname); | |
1296 | 1297 | |||
1297 | /* | 1298 | /* | |
1298 | * Prevent anyone from bringing the interface back up once | 1299 | * Prevent anyone from bringing the interface back up once | |
1299 | * we're detaching. | 1300 | * we're detaching. | |
1300 | */ | 1301 | */ | |
1301 | mutex_enter(&un->un_pri->unp_core_lock); | 1302 | mutex_enter(&un->un_pri->unp_core_lock); | |
1302 | dying = un->un_pri->unp_dying; | 1303 | dying = un->un_pri->unp_dying; | |
1303 | mutex_exit(&un->un_pri->unp_core_lock); | 1304 | mutex_exit(&un->un_pri->unp_core_lock); | |
1304 | if (dying) | 1305 | if (dying) | |
1305 | return EIO; | 1306 | return EIO; | |
1306 | 1307 | |||
1307 | return uno_init(un, ifp); | 1308 | mutex_enter(&un->un_pri->unp_core_lock); | |
1309 | error = uno_init(un, ifp); | |||
1310 | mutex_exit(&un->un_pri->unp_core_lock); | |||
1311 | ||||
1312 | return error; | |||
1308 | } | 1313 | } | |
1309 | 1314 | |||
1310 | 1315 | |||
1311 | /* Various accessors. */ | 1316 | /* Various accessors. */ | |
1312 | 1317 | |||
1313 | void | 1318 | void | |
1314 | usbnet_set_link(struct usbnet *un, bool link) | 1319 | usbnet_set_link(struct usbnet *un, bool link) | |
1315 | { | 1320 | { | |
1316 | un->un_pri->unp_link = link; | 1321 | un->un_pri->unp_link = link; | |
1317 | } | 1322 | } | |
1318 | 1323 | |||
1319 | struct ifnet * | 1324 | struct ifnet * | |
1320 | usbnet_ifp(struct usbnet *un) | 1325 | usbnet_ifp(struct usbnet *un) |