usbnet drivers: Omit needless uno_init locked subroutines. uno_init is now called with the core lock already held so there is no need for a separate locked subroutine.diff -r1.175 -r1.176 src/sys/dev/usb/if_aue.c
(riastradh)
--- src/sys/dev/usb/if_aue.c 2022/03/03 05:51:17 1.175
+++ src/sys/dev/usb/if_aue.c 2022/03/03 05:52:35 1.176
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_aue.c,v 1.175 2022/03/03 05:51:17 riastradh Exp $ */ | 1 | /* $NetBSD: if_aue.c,v 1.176 2022/03/03 05:52:35 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.175 2022/03/03 05:51:17 riastradh Exp $"); | 79 | __KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.176 2022/03/03 05:52:35 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,27 +944,27 @@ aue_uno_tx_prepare(struct usbnet *un, st | @@ -944,27 +944,27 @@ aue_uno_tx_prepare(struct usbnet *un, st | |||
944 | * and base the frame size on the bulk transfer length. | 944 | * and base the frame size on the bulk transfer length. | |
945 | */ | 945 | */ | |
946 | buf[0] = (uint8_t)m->m_pkthdr.len; | 946 | buf[0] = (uint8_t)m->m_pkthdr.len; | |
947 | buf[1] = (uint8_t)(m->m_pkthdr.len >> 8); | 947 | buf[1] = (uint8_t)(m->m_pkthdr.len >> 8); | |
948 | total_len = m->m_pkthdr.len + 2; | 948 | total_len = m->m_pkthdr.len + 2; | |
949 | 949 | |||
950 | DPRINTFN(5, "aue%jd: send %jd bytes", | 950 | DPRINTFN(5, "aue%jd: send %jd bytes", | |
951 | device_unit(un->un_dev), total_len, 0, 0); | 951 | device_unit(un->un_dev), total_len, 0, 0); | |
952 | 952 | |||
953 | return total_len; | 953 | return total_len; | |
954 | } | 954 | } | |
955 | 955 | |||
956 | static int | 956 | static int | |
957 | aue_init_locked(struct ifnet *ifp) | 957 | aue_uno_init(struct ifnet *ifp) | |
958 | { | 958 | { | |
959 | struct usbnet * const un = ifp->if_softc; | 959 | struct usbnet * const un = ifp->if_softc; | |
960 | struct aue_softc *sc = usbnet_softc(un); | 960 | struct aue_softc *sc = usbnet_softc(un); | |
961 | int i, rv; | 961 | int i, rv; | |
962 | const u_char *eaddr; | 962 | const u_char *eaddr; | |
963 | 963 | |||
964 | AUEHIST_FUNC(); | 964 | AUEHIST_FUNC(); | |
965 | AUEHIST_CALLARGSN(5, "aue%jd: enter link=%jd", | 965 | AUEHIST_CALLARGSN(5, "aue%jd: enter link=%jd", | |
966 | device_unit(un->un_dev), usbnet_havelink(un), 0, 0); | 966 | device_unit(un->un_dev), usbnet_havelink(un), 0, 0); | |
967 | 967 | |||
968 | if (usbnet_isdying(un)) | 968 | if (usbnet_isdying(un)) | |
969 | return EIO; | 969 | return EIO; | |
970 | 970 | |||
@@ -990,36 +990,26 @@ aue_init_locked(struct ifnet *ifp) | @@ -990,36 +990,26 @@ aue_init_locked(struct ifnet *ifp) | |||
990 | /* Load the multicast filter. */ | 990 | /* Load the multicast filter. */ | |
991 | aue_setiff_locked(un); | 991 | aue_setiff_locked(un); | |
992 | 992 | |||
993 | /* Enable RX and TX */ | 993 | /* Enable RX and TX */ | |
994 | aue_csr_write_1(sc, AUE_CTL0, AUE_CTL0_RXSTAT_APPEND | AUE_CTL0_RX_ENB); | 994 | aue_csr_write_1(sc, AUE_CTL0, AUE_CTL0_RXSTAT_APPEND | AUE_CTL0_RX_ENB); | |
995 | AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_TX_ENB); | 995 | AUE_SETBIT(sc, AUE_CTL0, AUE_CTL0_TX_ENB); | |
996 | AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR); | 996 | AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_EP3_CLR); | |
997 | 997 | |||
998 | //mii_mediachg(mii); | 998 | //mii_mediachg(mii); | |
999 | 999 | |||
1000 | return rv; | 1000 | return rv; | |
1001 | } | 1001 | } | |
1002 | 1002 | |||
1003 | static int | |||
1004 | aue_uno_init(struct ifnet *ifp) | |||
1005 | { | |||
1006 | int rv; | |||
1007 | ||||
1008 | rv = aue_init_locked(ifp); | |||
1009 | ||||
1010 | return rv; | |||
1011 | } | |||
1012 | ||||
1013 | static void | 1003 | static void | |
1014 | aue_uno_mcast(struct ifnet *ifp) | 1004 | aue_uno_mcast(struct ifnet *ifp) | |
1015 | { | 1005 | { | |
1016 | struct usbnet * const un = ifp->if_softc; | 1006 | struct usbnet * const un = ifp->if_softc; | |
1017 | 1007 | |||
1018 | AUEHIST_FUNC(); | 1008 | AUEHIST_FUNC(); | |
1019 | AUEHIST_CALLARGSN(5, "aue%jd: enter", | 1009 | AUEHIST_CALLARGSN(5, "aue%jd: enter", | |
1020 | device_unit(((struct usbnet *)(ifp->if_softc))->un_dev), | 1010 | device_unit(((struct usbnet *)(ifp->if_softc))->un_dev), | |
1021 | 0, 0, 0); | 1011 | 0, 0, 0); | |
1022 | 1012 | |||
1023 | /* | 1013 | /* | |
1024 | * XXX I feel like this is pretty heavy-handed! Maybe we could | 1014 | * XXX I feel like this is pretty heavy-handed! Maybe we could | |
1025 | * make do with aue_setiff_locked instead? | 1015 | * make do with aue_setiff_locked instead? |
--- src/sys/dev/usb/if_axe.c 2022/03/03 05:52:20 1.138
+++ src/sys/dev/usb/if_axe.c 2022/03/03 05:52:35 1.139
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_axe.c,v 1.138 2022/03/03 05:52:20 riastradh Exp $ */ | 1 | /* $NetBSD: if_axe.c,v 1.139 2022/03/03 05:52:35 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.138 2022/03/03 05:52:20 riastradh Exp $"); | 90 | __KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.139 2022/03/03 05:52:35 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 { | |
@@ -1200,27 +1200,27 @@ axe_csum_cfg(struct axe_softc *sc) | @@ -1200,27 +1200,27 @@ axe_csum_cfg(struct axe_softc *sc) | |||
1200 | if ((ifp->if_capenable & IFCAP_CSUM_TCPv4_Rx) != 0) | 1200 | if ((ifp->if_capenable & IFCAP_CSUM_TCPv4_Rx) != 0) | |
1201 | csum1 |= AXE_RXCSUM_TCP; | 1201 | csum1 |= AXE_RXCSUM_TCP; | |
1202 | if ((ifp->if_capenable & IFCAP_CSUM_UDPv4_Rx) != 0) | 1202 | if ((ifp->if_capenable & IFCAP_CSUM_UDPv4_Rx) != 0) | |
1203 | csum1 |= AXE_RXCSUM_UDP; | 1203 | csum1 |= AXE_RXCSUM_UDP; | |
1204 | if ((ifp->if_capenable & IFCAP_CSUM_TCPv6_Rx) != 0) | 1204 | if ((ifp->if_capenable & IFCAP_CSUM_TCPv6_Rx) != 0) | |
1205 | csum1 |= AXE_RXCSUM_TCPV6; | 1205 | csum1 |= AXE_RXCSUM_TCPV6; | |
1206 | if ((ifp->if_capenable & IFCAP_CSUM_UDPv6_Rx) != 0) | 1206 | if ((ifp->if_capenable & IFCAP_CSUM_UDPv6_Rx) != 0) | |
1207 | csum1 |= AXE_RXCSUM_UDPV6; | 1207 | csum1 |= AXE_RXCSUM_UDPV6; | |
1208 | axe_cmd(sc, AXE_772B_CMD_WRITE_RXCSUM, csum2, csum1, NULL); | 1208 | axe_cmd(sc, AXE_772B_CMD_WRITE_RXCSUM, csum2, csum1, NULL); | |
1209 | } | 1209 | } | |
1210 | } | 1210 | } | |
1211 | 1211 | |||
1212 | static int | 1212 | static int | |
1213 | axe_init_locked(struct ifnet *ifp) | 1213 | axe_uno_init(struct ifnet *ifp) | |
1214 | { | 1214 | { | |
1215 | AXEHIST_FUNC(); AXEHIST_CALLED(); | 1215 | AXEHIST_FUNC(); AXEHIST_CALLED(); | |
1216 | struct usbnet * const un = ifp->if_softc; | 1216 | struct usbnet * const un = ifp->if_softc; | |
1217 | struct axe_softc * const sc = usbnet_softc(un); | 1217 | struct axe_softc * const sc = usbnet_softc(un); | |
1218 | int rxmode; | 1218 | int rxmode; | |
1219 | 1219 | |||
1220 | usbnet_isowned_core(un); | 1220 | usbnet_isowned_core(un); | |
1221 | 1221 | |||
1222 | if (usbnet_isdying(un)) | 1222 | if (usbnet_isdying(un)) | |
1223 | return EIO; | 1223 | return EIO; | |
1224 | 1224 | |||
1225 | /* Cancel pending I/O */ | 1225 | /* Cancel pending I/O */ | |
1226 | usbnet_stop(un, ifp, 1); | 1226 | usbnet_stop(un, ifp, 1); | |
@@ -1296,34 +1296,26 @@ axe_init_locked(struct ifnet *ifp) | @@ -1296,34 +1296,26 @@ axe_init_locked(struct ifnet *ifp) | |||
1296 | } | 1296 | } | |
1297 | } | 1297 | } | |
1298 | 1298 | |||
1299 | DPRINTF("rxmode %#jx", rxmode, 0, 0, 0); | 1299 | DPRINTF("rxmode %#jx", rxmode, 0, 0, 0); | |
1300 | 1300 | |||
1301 | axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL); | 1301 | axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL); | |
1302 | 1302 | |||
1303 | /* Accept multicast frame or run promisc. mode */ | 1303 | /* Accept multicast frame or run promisc. mode */ | |
1304 | axe_rcvfilt_locked(un); | 1304 | axe_rcvfilt_locked(un); | |
1305 | 1305 | |||
1306 | return usbnet_init_rx_tx(un); | 1306 | return usbnet_init_rx_tx(un); | |
1307 | } | 1307 | } | |
1308 | 1308 | |||
1309 | static int | |||
1310 | axe_uno_init(struct ifnet *ifp) | |||
1311 | { | |||
1312 | int ret = axe_init_locked(ifp); | |||
1313 | ||||
1314 | return ret; | |||
1315 | } | |||
1316 | ||||
1317 | static void | 1309 | static void | |
1318 | axe_uno_mcast(struct ifnet *ifp) | 1310 | axe_uno_mcast(struct ifnet *ifp) | |
1319 | { | 1311 | { | |
1320 | struct usbnet * const un = ifp->if_softc; | 1312 | struct usbnet * const un = ifp->if_softc; | |
1321 | 1313 | |||
1322 | usbnet_lock_core(un); | 1314 | usbnet_lock_core(un); | |
1323 | 1315 | |||
1324 | axe_rcvfilt_locked(un); | 1316 | axe_rcvfilt_locked(un); | |
1325 | 1317 | |||
1326 | usbnet_unlock_core(un); | 1318 | usbnet_unlock_core(un); | |
1327 | } | 1319 | } | |
1328 | 1320 | |||
1329 | static void | 1321 | static void |
--- src/sys/dev/usb/if_axen.c 2022/03/03 05:51:44 1.80
+++ src/sys/dev/usb/if_axen.c 2022/03/03 05:52:35 1.81
@@ -1,39 +1,39 @@ | @@ -1,39 +1,39 @@ | |||
1 | /* $NetBSD: if_axen.c,v 1.80 2022/03/03 05:51:44 riastradh Exp $ */ | 1 | /* $NetBSD: if_axen.c,v 1.81 2022/03/03 05:52:35 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.80 2022/03/03 05:51:44 riastradh Exp $"); | 26 | __KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.81 2022/03/03 05:52:35 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> | |
@@ -884,27 +884,27 @@ axen_uno_tx_prepare(struct usbnet *un, s | @@ -884,27 +884,27 @@ axen_uno_tx_prepare(struct usbnet *un, s | |||
884 | if ((length % boundary) == 0) { | 884 | if ((length % boundary) == 0) { | |
885 | DPRINTF(("%s: boundary hit\n", device_xname(un->un_dev))); | 885 | DPRINTF(("%s: boundary hit\n", device_xname(un->un_dev))); | |
886 | hdr.gso |= 0x80008000; /* XXX enable padding */ | 886 | hdr.gso |= 0x80008000; /* XXX enable padding */ | |
887 | } | 887 | } | |
888 | hdr.gso = htole32(hdr.gso); | 888 | hdr.gso = htole32(hdr.gso); | |
889 | 889 | |||
890 | memcpy(c->unc_buf, &hdr, sizeof(hdr)); | 890 | memcpy(c->unc_buf, &hdr, sizeof(hdr)); | |
891 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + sizeof(hdr)); | 891 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + sizeof(hdr)); | |
892 | 892 | |||
893 | return length; | 893 | return length; | |
894 | } | 894 | } | |
895 | 895 | |||
896 | static int | 896 | static int | |
897 | axen_init_locked(struct ifnet *ifp) | 897 | axen_uno_init(struct ifnet *ifp) | |
898 | { | 898 | { | |
899 | struct usbnet * const un = ifp->if_softc; | 899 | struct usbnet * const un = ifp->if_softc; | |
900 | uint16_t rxmode; | 900 | uint16_t rxmode; | |
901 | uint16_t wval; | 901 | uint16_t wval; | |
902 | uint8_t bval; | 902 | uint8_t bval; | |
903 | 903 | |||
904 | usbnet_isowned_core(un); | 904 | usbnet_isowned_core(un); | |
905 | 905 | |||
906 | if (usbnet_isdying(un)) | 906 | if (usbnet_isdying(un)) | |
907 | return EIO; | 907 | return EIO; | |
908 | 908 | |||
909 | /* Cancel pending I/O */ | 909 | /* Cancel pending I/O */ | |
910 | usbnet_stop(un, ifp, 1); | 910 | usbnet_stop(un, ifp, 1); | |
@@ -922,34 +922,26 @@ axen_init_locked(struct ifnet *ifp) | @@ -922,34 +922,26 @@ axen_init_locked(struct ifnet *ifp) | |||
922 | /* Program promiscuous mode and multicast filters. */ | 922 | /* Program promiscuous mode and multicast filters. */ | |
923 | axen_setiff_locked(un); | 923 | axen_setiff_locked(un); | |
924 | 924 | |||
925 | /* Enable receiver, set RX mode */ | 925 | /* Enable receiver, set RX mode */ | |
926 | axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval); | 926 | axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval); | |
927 | rxmode = le16toh(wval); | 927 | rxmode = le16toh(wval); | |
928 | rxmode |= AXEN_RXCTL_START; | 928 | rxmode |= AXEN_RXCTL_START; | |
929 | wval = htole16(rxmode); | 929 | wval = htole16(rxmode); | |
930 | axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); | 930 | axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); | |
931 | 931 | |||
932 | return usbnet_init_rx_tx(un); | 932 | return usbnet_init_rx_tx(un); | |
933 | } | 933 | } | |
934 | 934 | |||
935 | static int | |||
936 | axen_uno_init(struct ifnet *ifp) | |||
937 | { | |||
938 | int ret = axen_init_locked(ifp); | |||
939 | ||||
940 | return ret; | |||
941 | } | |||
942 | ||||
943 | static void | 935 | static void | |
944 | axen_uno_stop(struct ifnet *ifp, int disable) | 936 | axen_uno_stop(struct ifnet *ifp, int disable) | |
945 | { | 937 | { | |
946 | struct usbnet * const un = ifp->if_softc; | 938 | struct usbnet * const un = ifp->if_softc; | |
947 | uint16_t rxmode, wval; | 939 | uint16_t rxmode, wval; | |
948 | 940 | |||
949 | axen_reset(un); | 941 | axen_reset(un); | |
950 | 942 | |||
951 | /* Disable receiver, set RX mode */ | 943 | /* Disable receiver, set RX mode */ | |
952 | axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval); | 944 | axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval); | |
953 | rxmode = le16toh(wval); | 945 | rxmode = le16toh(wval); | |
954 | rxmode &= ~AXEN_RXCTL_START; | 946 | rxmode &= ~AXEN_RXCTL_START; | |
955 | wval = htole16(rxmode); | 947 | wval = htole16(rxmode); |
--- src/sys/dev/usb/if_cue.c 2022/03/03 05:51:27 1.96
+++ src/sys/dev/usb/if_cue.c 2022/03/03 05:52:35 1.97
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_cue.c,v 1.96 2022/03/03 05:51:27 riastradh Exp $ */ | 1 | /* $NetBSD: if_cue.c,v 1.97 2022/03/03 05:52:35 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.96 2022/03/03 05:51:27 riastradh Exp $"); | 60 | __KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.97 2022/03/03 05:52:35 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> | |
@@ -603,27 +603,27 @@ cue_uno_tx_prepare(struct usbnet *un, st | @@ -603,27 +603,27 @@ cue_uno_tx_prepare(struct usbnet *un, st | |||
603 | */ | 603 | */ | |
604 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + 2); | 604 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + 2); | |
605 | 605 | |||
606 | total_len = m->m_pkthdr.len + 2; | 606 | total_len = m->m_pkthdr.len + 2; | |
607 | 607 | |||
608 | /* The first two bytes are the frame length */ | 608 | /* The first two bytes are the frame length */ | |
609 | c->unc_buf[0] = (uint8_t)m->m_pkthdr.len; | 609 | c->unc_buf[0] = (uint8_t)m->m_pkthdr.len; | |
610 | c->unc_buf[1] = (uint8_t)(m->m_pkthdr.len >> 8); | 610 | c->unc_buf[1] = (uint8_t)(m->m_pkthdr.len >> 8); | |
611 | 611 | |||
612 | return total_len; | 612 | return total_len; | |
613 | } | 613 | } | |
614 | 614 | |||
615 | static int | 615 | static int | |
616 | cue_init_locked(struct ifnet *ifp) | 616 | cue_uno_init(struct ifnet *ifp) | |
617 | { | 617 | { | |
618 | struct usbnet * const un = ifp->if_softc; | 618 | struct usbnet * const un = ifp->if_softc; | |
619 | int i, ctl; | 619 | int i, ctl; | |
620 | const u_char *eaddr; | 620 | const u_char *eaddr; | |
621 | 621 | |||
622 | DPRINTFN(10,("%s: %s: enter\n", device_xname(un->un_dev),__func__)); | 622 | DPRINTFN(10,("%s: %s: enter\n", device_xname(un->un_dev),__func__)); | |
623 | 623 | |||
624 | if (usbnet_isdying(un)) | 624 | if (usbnet_isdying(un)) | |
625 | return ENXIO; | 625 | return ENXIO; | |
626 | 626 | |||
627 | /* Cancel pending I/O */ | 627 | /* Cancel pending I/O */ | |
628 | usbnet_stop(un, ifp, 1); | 628 | usbnet_stop(un, ifp, 1); | |
629 | 629 | |||
@@ -657,36 +657,26 @@ cue_init_locked(struct ifnet *ifp) | @@ -657,36 +657,26 @@ cue_init_locked(struct ifnet *ifp) | |||
657 | cue_csr_write_1(un, CUE_RX_BUFPKTS, CUE_RX_FRAMES); | 657 | cue_csr_write_1(un, CUE_RX_BUFPKTS, CUE_RX_FRAMES); | |
658 | cue_csr_write_1(un, CUE_TX_BUFPKTS, CUE_TX_FRAMES); | 658 | cue_csr_write_1(un, CUE_TX_BUFPKTS, CUE_TX_FRAMES); | |
659 | 659 | |||
660 | /* Set advanced operation modes. */ | 660 | /* Set advanced operation modes. */ | |
661 | cue_csr_write_1(un, CUE_ADVANCED_OPMODES, | 661 | cue_csr_write_1(un, CUE_ADVANCED_OPMODES, | |
662 | CUE_AOP_EMBED_RXLEN | 0x01); /* 1 wait state */ | 662 | CUE_AOP_EMBED_RXLEN | 0x01); /* 1 wait state */ | |
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 | |||
671 | cue_uno_init(struct ifnet *ifp) | |||
672 | { | |||
673 | int rv; | |||
674 | ||||
675 | rv = cue_init_locked(ifp); | |||
676 | ||||
677 | return rv; | |||
678 | } | |||
679 | ||||
680 | static void | 670 | static void | |
681 | cue_uno_mcast(struct ifnet *ifp) | 671 | cue_uno_mcast(struct ifnet *ifp) | |
682 | { | 672 | { | |
683 | struct usbnet * const un = ifp->if_softc; | 673 | struct usbnet * const un = ifp->if_softc; | |
684 | 674 | |||
685 | usbnet_lock_core(un); | 675 | usbnet_lock_core(un); | |
686 | 676 | |||
687 | cue_setiff_locked(un); | 677 | cue_setiff_locked(un); | |
688 | 678 | |||
689 | usbnet_unlock_core(un); | 679 | usbnet_unlock_core(un); | |
690 | } | 680 | } | |
691 | 681 | |||
692 | /* Stop and reset the adapter. */ | 682 | /* Stop and reset the adapter. */ |
--- src/sys/dev/usb/if_kue.c 2022/03/03 05:51:27 1.109
+++ src/sys/dev/usb/if_kue.c 2022/03/03 05:52:35 1.110
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_kue.c,v 1.109 2022/03/03 05:51:27 riastradh Exp $ */ | 1 | /* $NetBSD: if_kue.c,v 1.110 2022/03/03 05:52:35 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.109 2022/03/03 05:51:27 riastradh Exp $"); | 74 | __KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.110 2022/03/03 05:52:35 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> | |
@@ -581,27 +581,27 @@ kue_uno_tx_prepare(struct usbnet *un, st | @@ -581,27 +581,27 @@ kue_uno_tx_prepare(struct usbnet *un, st | |||
581 | * possibly zeroing the rest of the buffer. | 581 | * possibly zeroing the rest of the buffer. | |
582 | */ | 582 | */ | |
583 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + 2); | 583 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf + 2); | |
584 | if (total_len - pkt_len > 0) | 584 | if (total_len - pkt_len > 0) | |
585 | memset(c->unc_buf + pkt_len, 0, total_len - pkt_len); | 585 | memset(c->unc_buf + pkt_len, 0, total_len - pkt_len); | |
586 | 586 | |||
587 | DPRINTFN(10,("%s: %s: enter pktlen %u total %u\n", | 587 | DPRINTFN(10,("%s: %s: enter pktlen %u total %u\n", | |
588 | device_xname(un->un_dev), __func__, pkt_len, total_len)); | 588 | device_xname(un->un_dev), __func__, pkt_len, total_len)); | |
589 | 589 | |||
590 | return total_len; | 590 | return total_len; | |
591 | } | 591 | } | |
592 | 592 | |||
593 | static int | 593 | static int | |
594 | kue_init_locked(struct ifnet *ifp) | 594 | kue_uno_init(struct ifnet *ifp) | |
595 | { | 595 | { | |
596 | struct usbnet * const un = ifp->if_softc; | 596 | struct usbnet * const un = ifp->if_softc; | |
597 | struct kue_softc *sc = usbnet_softc(un); | 597 | struct kue_softc *sc = usbnet_softc(un); | |
598 | uint8_t eaddr[ETHER_ADDR_LEN]; | 598 | uint8_t eaddr[ETHER_ADDR_LEN]; | |
599 | 599 | |||
600 | DPRINTFN(5,("%s: %s: enter\n", device_xname(un->un_dev),__func__)); | 600 | DPRINTFN(5,("%s: %s: enter\n", device_xname(un->un_dev),__func__)); | |
601 | 601 | |||
602 | if (usbnet_isdying(un)) | 602 | if (usbnet_isdying(un)) | |
603 | return EIO; | 603 | return EIO; | |
604 | 604 | |||
605 | /* Cancel pending I/O */ | 605 | /* Cancel pending I/O */ | |
606 | usbnet_stop(un, ifp, 1); | 606 | usbnet_stop(un, ifp, 1); | |
607 | 607 | |||
@@ -617,36 +617,26 @@ kue_init_locked(struct ifnet *ifp) | @@ -617,36 +617,26 @@ kue_init_locked(struct ifnet *ifp) | |||
617 | * Leave this one alone for now; setting it | 617 | * Leave this one alone for now; setting it | |
618 | * wrong causes lockups on some machines/controllers. | 618 | * wrong causes lockups on some machines/controllers. | |
619 | */ | 619 | */ | |
620 | kue_setword(un, KUE_CMD_SET_SOFS, 1); | 620 | kue_setword(un, KUE_CMD_SET_SOFS, 1); | |
621 | #endif | 621 | #endif | |
622 | kue_setword(un, KUE_CMD_SET_URB_SIZE, 64); | 622 | kue_setword(un, KUE_CMD_SET_URB_SIZE, 64); | |
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 | |||
631 | kue_uno_init(struct ifnet *ifp) | |||
632 | { | |||
633 | int rv; | |||
634 | ||||
635 | rv = kue_init_locked(ifp); | |||
636 | ||||
637 | return rv; | |||
638 | } | |||
639 | ||||
640 | static void | 630 | static void | |
641 | kue_uno_mcast(struct ifnet *ifp) | 631 | kue_uno_mcast(struct ifnet *ifp) | |
642 | { | 632 | { | |
643 | struct usbnet * const un = ifp->if_softc; | 633 | struct usbnet * const un = ifp->if_softc; | |
644 | 634 | |||
645 | usbnet_lock_core(un); | 635 | usbnet_lock_core(un); | |
646 | 636 | |||
647 | kue_setiff_locked(un); | 637 | kue_setiff_locked(un); | |
648 | 638 | |||
649 | usbnet_unlock_core(un); | 639 | usbnet_unlock_core(un); | |
650 | } | 640 | } | |
651 | 641 | |||
652 | #ifdef _MODULE | 642 | #ifdef _MODULE |
--- src/sys/dev/usb/if_mos.c 2022/03/03 05:51:27 1.12
+++ src/sys/dev/usb/if_mos.c 2022/03/03 05:52:35 1.13
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_mos.c,v 1.12 2022/03/03 05:51:27 riastradh Exp $ */ | 1 | /* $NetBSD: if_mos.c,v 1.13 2022/03/03 05:52:35 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.12 2022/03/03 05:51:27 riastradh Exp $"); | 75 | __KERNEL_RCSID(0, "$NetBSD: if_mos.c,v 1.13 2022/03/03 05:52:35 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 | |||
@@ -713,27 +713,27 @@ mos_uno_tx_prepare(struct usbnet *un, st | @@ -713,27 +713,27 @@ mos_uno_tx_prepare(struct usbnet *un, st | |||
713 | if ((unsigned)m->m_pkthdr.len > un->un_tx_bufsz) | 713 | if ((unsigned)m->m_pkthdr.len > un->un_tx_bufsz) | |
714 | return 0; | 714 | return 0; | |
715 | 715 | |||
716 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf); | 716 | m_copydata(m, 0, m->m_pkthdr.len, c->unc_buf); | |
717 | length = m->m_pkthdr.len; | 717 | length = m->m_pkthdr.len; | |
718 | 718 | |||
719 | DPRINTFN(5,("%s: %s: len %u\n", | 719 | DPRINTFN(5,("%s: %s: len %u\n", | |
720 | device_xname(un->un_dev), __func__, length)); | 720 | device_xname(un->un_dev), __func__, length)); | |
721 | 721 | |||
722 | return length; | 722 | return length; | |
723 | } | 723 | } | |
724 | 724 | |||
725 | static int | 725 | static int | |
726 | mos_init_locked(struct ifnet *ifp) | 726 | mos_uno_init(struct ifnet *ifp) | |
727 | { | 727 | { | |
728 | struct usbnet * const un = ifp->if_softc; | 728 | struct usbnet * const un = ifp->if_softc; | |
729 | u_int8_t rxmode; | 729 | u_int8_t rxmode; | |
730 | unsigned char ipgs[2]; | 730 | unsigned char ipgs[2]; | |
731 | 731 | |||
732 | if (usbnet_isdying(un)) | 732 | if (usbnet_isdying(un)) | |
733 | return EIO; | 733 | return EIO; | |
734 | 734 | |||
735 | /* Cancel pending I/O */ | 735 | /* Cancel pending I/O */ | |
736 | usbnet_stop(un, ifp, 1); | 736 | usbnet_stop(un, ifp, 1); | |
737 | 737 | |||
738 | /* Reset the ethernet interface. */ | 738 | /* Reset the ethernet interface. */ | |
739 | mos_reset(un); | 739 | mos_reset(un); | |
@@ -749,34 +749,26 @@ mos_init_locked(struct ifnet *ifp) | @@ -749,34 +749,26 @@ mos_init_locked(struct ifnet *ifp) | |||
749 | 749 | |||
750 | /* Accept multicast frame or run promisc. mode */ | 750 | /* Accept multicast frame or run promisc. mode */ | |
751 | mos_rcvfilt_locked(un); | 751 | mos_rcvfilt_locked(un); | |
752 | 752 | |||
753 | /* Enable receiver and transmitter, bridge controls speed/duplex mode */ | 753 | /* Enable receiver and transmitter, bridge controls speed/duplex mode */ | |
754 | rxmode = mos_reg_read_1(un, MOS_CTL); | 754 | rxmode = mos_reg_read_1(un, MOS_CTL); | |
755 | rxmode |= MOS_CTL_RX_ENB | MOS_CTL_TX_ENB | MOS_CTL_BS_ENB; | 755 | rxmode |= MOS_CTL_RX_ENB | MOS_CTL_TX_ENB | MOS_CTL_BS_ENB; | |
756 | rxmode &= ~(MOS_CTL_SLEEP); | 756 | rxmode &= ~(MOS_CTL_SLEEP); | |
757 | mos_reg_write_1(un, MOS_CTL, rxmode); | 757 | mos_reg_write_1(un, MOS_CTL, rxmode); | |
758 | 758 | |||
759 | return usbnet_init_rx_tx(un); | 759 | return usbnet_init_rx_tx(un); | |
760 | } | 760 | } | |
761 | 761 | |||
762 | static int | |||
763 | mos_uno_init(struct ifnet *ifp) | |||
764 | { | |||
765 | int ret = mos_init_locked(ifp); | |||
766 | ||||
767 | return ret; | |||
768 | } | |||
769 | ||||
770 | static void | 762 | static void | |
771 | mos_uno_mcast(struct ifnet *ifp) | 763 | mos_uno_mcast(struct ifnet *ifp) | |
772 | { | 764 | { | |
773 | struct usbnet * const un = ifp->if_softc; | 765 | struct usbnet * const un = ifp->if_softc; | |
774 | 766 | |||
775 | usbnet_lock_core(un); | 767 | usbnet_lock_core(un); | |
776 | 768 | |||
777 | mos_rcvfilt_locked(un); | 769 | mos_rcvfilt_locked(un); | |
778 | 770 | |||
779 | usbnet_unlock_core(un); | 771 | usbnet_unlock_core(un); | |
780 | } | 772 | } | |
781 | 773 | |||
782 | void | 774 | void |
--- src/sys/dev/usb/if_mue.c 2022/03/03 05:51:35 1.69
+++ src/sys/dev/usb/if_mue.c 2022/03/03 05:52:35 1.70
@@ -1,36 +1,36 @@ | @@ -1,36 +1,36 @@ | |||
1 | /* $NetBSD: if_mue.c,v 1.69 2022/03/03 05:51:35 riastradh Exp $ */ | 1 | /* $NetBSD: if_mue.c,v 1.70 2022/03/03 05:52:35 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.69 2022/03/03 05:51:35 riastradh Exp $"); | 23 | __KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.70 2022/03/03 05:52:35 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 | |||
@@ -1213,27 +1213,27 @@ mue_uno_rx_loop(struct usbnet *un, struc | @@ -1213,27 +1213,27 @@ mue_uno_rx_loop(struct usbnet *un, struc | |||
1213 | usbnet_enqueue(un, buf + sizeof(*hdrp), pktlen, csum, | 1213 | usbnet_enqueue(un, buf + sizeof(*hdrp), pktlen, csum, | |
1214 | 0, M_HASFCS); | 1214 | 0, M_HASFCS); | |
1215 | 1215 | |||
1216 | /* Attention: sizeof(hdr) = 10 */ | 1216 | /* Attention: sizeof(hdr) = 10 */ | |
1217 | pktlen = roundup(pktlen + sizeof(*hdrp), 4); | 1217 | pktlen = roundup(pktlen + sizeof(*hdrp), 4); | |
1218 | if (pktlen > total_len) | 1218 | if (pktlen > total_len) | |
1219 | pktlen = total_len; | 1219 | pktlen = total_len; | |
1220 | total_len -= pktlen; | 1220 | total_len -= pktlen; | |
1221 | buf += pktlen; | 1221 | buf += pktlen; | |
1222 | } while (total_len > 0); | 1222 | } while (total_len > 0); | |
1223 | } | 1223 | } | |
1224 | 1224 | |||
1225 | static int | 1225 | static int | |
1226 | mue_init_locked(struct ifnet *ifp) | 1226 | mue_uno_init(struct ifnet *ifp) | |
1227 | { | 1227 | { | |
1228 | struct usbnet * const un = ifp->if_softc; | 1228 | struct usbnet * const un = ifp->if_softc; | |
1229 | 1229 | |||
1230 | if (usbnet_isdying(un)) { | 1230 | if (usbnet_isdying(un)) { | |
1231 | DPRINTF(un, "dying\n"); | 1231 | DPRINTF(un, "dying\n"); | |
1232 | return EIO; | 1232 | return EIO; | |
1233 | } | 1233 | } | |
1234 | 1234 | |||
1235 | /* Cancel pending I/O and free all TX/RX buffers. */ | 1235 | /* Cancel pending I/O and free all TX/RX buffers. */ | |
1236 | if (ifp->if_flags & IFF_RUNNING) | 1236 | if (ifp->if_flags & IFF_RUNNING) | |
1237 | usbnet_stop(un, ifp, 1); | 1237 | usbnet_stop(un, ifp, 1); | |
1238 | 1238 | |||
1239 | mue_reset(un); | 1239 | mue_reset(un); | |
@@ -1244,36 +1244,26 @@ mue_init_locked(struct ifnet *ifp) | @@ -1244,36 +1244,26 @@ mue_init_locked(struct ifnet *ifp) | |||
1244 | /* Load the multicast filter. */ | 1244 | /* Load the multicast filter. */ | |
1245 | mue_setiff_locked(un); | 1245 | mue_setiff_locked(un); | |
1246 | 1246 | |||
1247 | /* TCP/UDP checksum offload engines. */ | 1247 | /* TCP/UDP checksum offload engines. */ | |
1248 | mue_sethwcsum_locked(un); | 1248 | mue_sethwcsum_locked(un); | |
1249 | 1249 | |||
1250 | /* Set MTU. */ | 1250 | /* Set MTU. */ | |
1251 | mue_setmtu_locked(un); | 1251 | mue_setmtu_locked(un); | |
1252 | 1252 | |||
1253 | return usbnet_init_rx_tx(un); | 1253 | return usbnet_init_rx_tx(un); | |
1254 | } | 1254 | } | |
1255 | 1255 | |||
1256 | static int | 1256 | static int | |
1257 | mue_uno_init(struct ifnet *ifp) | |||
1258 | { | |||
1259 | int rv; | |||
1260 | ||||
1261 | rv = mue_init_locked(ifp); | |||
1262 | ||||
1263 | return rv; | |||
1264 | } | |||
1265 | ||||
1266 | static int | |||
1267 | mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | 1257 | mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) | |
1268 | { | 1258 | { | |
1269 | struct usbnet * const un = ifp->if_softc; | 1259 | struct usbnet * const un = ifp->if_softc; | |
1270 | 1260 | |||
1271 | usbnet_lock_core(un); | 1261 | usbnet_lock_core(un); | |
1272 | 1262 | |||
1273 | switch (cmd) { | 1263 | switch (cmd) { | |
1274 | case SIOCSIFCAP: | 1264 | case SIOCSIFCAP: | |
1275 | mue_sethwcsum_locked(un); | 1265 | mue_sethwcsum_locked(un); | |
1276 | break; | 1266 | break; | |
1277 | case SIOCSIFMTU: | 1267 | case SIOCSIFMTU: | |
1278 | mue_setmtu_locked(un); | 1268 | mue_setmtu_locked(un); | |
1279 | break; | 1269 | break; |
--- src/sys/dev/usb/if_smsc.c 2022/03/03 05:51:44 1.78
+++ src/sys/dev/usb/if_smsc.c 2022/03/03 05:52:35 1.79
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_smsc.c,v 1.78 2022/03/03 05:51:44 riastradh Exp $ */ | 1 | /* $NetBSD: if_smsc.c,v 1.79 2022/03/03 05:52:35 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.78 2022/03/03 05:51:44 riastradh Exp $"); | 64 | __KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.79 2022/03/03 05:52:35 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" | |
@@ -164,27 +164,26 @@ fail: | @@ -164,27 +164,26 @@ fail: | |||
164 | printf("%s: error: " fmt, device_xname((un)->un_dev), ##args) | 164 | printf("%s: error: " fmt, device_xname((un)->un_dev), ##args) | |
165 | 165 | |||
166 | /* Function declarations */ | 166 | /* Function declarations */ | |
167 | static int smsc_match(device_t, cfdata_t, void *); | 167 | static int smsc_match(device_t, cfdata_t, void *); | |
168 | static void smsc_attach(device_t, device_t, void *); | 168 | static void smsc_attach(device_t, device_t, void *); | |
169 | 169 | |||
170 | CFATTACH_DECL_NEW(usmsc, sizeof(struct smsc_softc), | 170 | CFATTACH_DECL_NEW(usmsc, sizeof(struct smsc_softc), | |
171 | smsc_match, smsc_attach, usbnet_detach, usbnet_activate); | 171 | smsc_match, smsc_attach, usbnet_detach, usbnet_activate); | |
172 | 172 | |||
173 | static int smsc_chip_init(struct usbnet *); | 173 | static int smsc_chip_init(struct usbnet *); | |
174 | static int smsc_setmacaddress(struct usbnet *, const uint8_t *); | 174 | static int smsc_setmacaddress(struct usbnet *, const uint8_t *); | |
175 | 175 | |||
176 | static int smsc_uno_init(struct ifnet *); | 176 | static int smsc_uno_init(struct ifnet *); | |
177 | static int smsc_init_locked(struct ifnet *); | |||
178 | static void smsc_uno_stop(struct ifnet *, int); | 177 | static void smsc_uno_stop(struct ifnet *, int); | |
179 | 178 | |||
180 | static void smsc_reset(struct smsc_softc *); | 179 | static void smsc_reset(struct smsc_softc *); | |
181 | 180 | |||
182 | static void smsc_uno_miibus_statchg(struct ifnet *); | 181 | static void smsc_uno_miibus_statchg(struct ifnet *); | |
183 | static int smsc_readreg(struct usbnet *, uint32_t, uint32_t *); | 182 | static int smsc_readreg(struct usbnet *, uint32_t, uint32_t *); | |
184 | static int smsc_writereg(struct usbnet *, uint32_t, uint32_t); | 183 | static int smsc_writereg(struct usbnet *, uint32_t, uint32_t); | |
185 | static int smsc_wait_for_bits(struct usbnet *, uint32_t, uint32_t); | 184 | static int smsc_wait_for_bits(struct usbnet *, uint32_t, uint32_t); | |
186 | static int smsc_uno_miibus_readreg(struct usbnet *, int, int, uint16_t *); | 185 | static int smsc_uno_miibus_readreg(struct usbnet *, int, int, uint16_t *); | |
187 | static int smsc_uno_miibus_writereg(struct usbnet *, int, int, uint16_t); | 186 | static int smsc_uno_miibus_writereg(struct usbnet *, int, int, uint16_t); | |
188 | 187 | |||
189 | static int smsc_uno_ioctl(struct ifnet *, u_long, void *); | 188 | static int smsc_uno_ioctl(struct ifnet *, u_long, void *); | |
190 | static void smsc_uno_mcast(struct ifnet *); | 189 | static void smsc_uno_mcast(struct ifnet *); | |
@@ -544,34 +543,26 @@ smsc_reset(struct smsc_softc *sc) | @@ -544,34 +543,26 @@ smsc_reset(struct smsc_softc *sc) | |||
544 | if (usbnet_isdying(un)) | 543 | if (usbnet_isdying(un)) | |
545 | return; | 544 | return; | |
546 | 545 | |||
547 | /* Wait a little while for the chip to get its brains in order. */ | 546 | /* Wait a little while for the chip to get its brains in order. */ | |
548 | DELAY(1000); | 547 | DELAY(1000); | |
549 | 548 | |||
550 | /* Reinitialize controller to achieve full reset. */ | 549 | /* Reinitialize controller to achieve full reset. */ | |
551 | smsc_chip_init(un); | 550 | smsc_chip_init(un); | |
552 | } | 551 | } | |
553 | 552 | |||
554 | static int | 553 | static int | |
555 | smsc_uno_init(struct ifnet *ifp) | 554 | smsc_uno_init(struct ifnet *ifp) | |
556 | { | 555 | { | |
557 | int ret = smsc_init_locked(ifp); | |||
558 | ||||
559 | return ret; | |||
560 | } | |||
561 | ||||
562 | static int | |||
563 | smsc_init_locked(struct ifnet *ifp) | |||
564 | { | |||
565 | struct usbnet * const un = ifp->if_softc; | 556 | struct usbnet * const un = ifp->if_softc; | |
566 | struct smsc_softc * const sc = usbnet_softc(un); | 557 | struct smsc_softc * const sc = usbnet_softc(un); | |
567 | 558 | |||
568 | usbnet_isowned_core(un); | 559 | usbnet_isowned_core(un); | |
569 | 560 | |||
570 | if (usbnet_isdying(un)) | 561 | if (usbnet_isdying(un)) | |
571 | return EIO; | 562 | return EIO; | |
572 | 563 | |||
573 | /* Cancel pending I/O */ | 564 | /* Cancel pending I/O */ | |
574 | usbnet_stop(un, ifp, 1); | 565 | usbnet_stop(un, ifp, 1); | |
575 | 566 | |||
576 | /* Reset the ethernet interface. */ | 567 | /* Reset the ethernet interface. */ | |
577 | smsc_reset(sc); | 568 | smsc_reset(sc); |
--- src/sys/dev/usb/if_ure.c 2022/03/03 05:51:27 1.45
+++ src/sys/dev/usb/if_ure.c 2022/03/03 05:52:35 1.46
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ure.c,v 1.45 2022/03/03 05:51:27 riastradh Exp $ */ | 1 | /* $NetBSD: if_ure.c,v 1.46 2022/03/03 05:52:35 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.45 2022/03/03 05:51:27 riastradh Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.46 2022/03/03 05:52:35 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 | |||
@@ -398,27 +398,27 @@ ure_reset(struct usbnet *un) | @@ -398,27 +398,27 @@ ure_reset(struct usbnet *un) | |||
398 | for (i = 0; i < URE_TIMEOUT; i++) { | 398 | for (i = 0; i < URE_TIMEOUT; i++) { | |
399 | if (usbnet_isdying(un)) | 399 | if (usbnet_isdying(un)) | |
400 | return; | 400 | return; | |
401 | if (!(ure_read_1(un, URE_PLA_CR, URE_MCU_TYPE_PLA) & | 401 | if (!(ure_read_1(un, URE_PLA_CR, URE_MCU_TYPE_PLA) & | |
402 | URE_CR_RST)) | 402 | URE_CR_RST)) | |
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_init_locked(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 | usbnet_isowned_core(un); | 416 | usbnet_isowned_core(un); | |
417 | 417 | |||
418 | if (usbnet_isdying(un)) | 418 | if (usbnet_isdying(un)) | |
419 | return EIO; | 419 | return EIO; | |
420 | 420 | |||
421 | /* Cancel pending I/O. */ | 421 | /* Cancel pending I/O. */ | |
422 | if (ifp->if_flags & IFF_RUNNING) | 422 | if (ifp->if_flags & IFF_RUNNING) | |
423 | usbnet_stop(un, ifp, 1); | 423 | usbnet_stop(un, ifp, 1); | |
424 | 424 | |||
@@ -443,34 +443,26 @@ ure_init_locked(struct ifnet *ifp) | @@ -443,34 +443,26 @@ ure_init_locked(struct ifnet *ifp) | |||
443 | ure_read_1(un, URE_PLA_CR, URE_MCU_TYPE_PLA) | URE_CR_RE | | 443 | ure_read_1(un, URE_PLA_CR, URE_MCU_TYPE_PLA) | URE_CR_RE | | |
444 | URE_CR_TE); | 444 | URE_CR_TE); | |
445 | 445 | |||
446 | ure_write_2(un, URE_PLA_MISC_1, URE_MCU_TYPE_PLA, | 446 | ure_write_2(un, URE_PLA_MISC_1, URE_MCU_TYPE_PLA, | |
447 | ure_read_2(un, URE_PLA_MISC_1, URE_MCU_TYPE_PLA) & | 447 | ure_read_2(un, URE_PLA_MISC_1, URE_MCU_TYPE_PLA) & | |
448 | ~URE_RXDY_GATED_EN); | 448 | ~URE_RXDY_GATED_EN); | |
449 | 449 | |||
450 | /* Accept multicast frame or run promisc. mode. */ | 450 | /* Accept multicast frame or run promisc. mode. */ | |
451 | ure_rcvfilt_locked(un); | 451 | ure_rcvfilt_locked(un); | |
452 | 452 | |||
453 | return usbnet_init_rx_tx(un); | 453 | return usbnet_init_rx_tx(un); | |
454 | } | 454 | } | |
455 | 455 | |||
456 | static int | |||
457 | ure_uno_init(struct ifnet *ifp) | |||
458 | { | |||
459 | int ret = ure_init_locked(ifp); | |||
460 | ||||
461 | return ret; | |||
462 | } | |||
463 | ||||
464 | static void | 456 | static void | |
465 | ure_uno_stop(struct ifnet *ifp, int disable __unused) | 457 | ure_uno_stop(struct ifnet *ifp, int disable __unused) | |
466 | { | 458 | { | |
467 | struct usbnet * const un = ifp->if_softc; | 459 | struct usbnet * const un = ifp->if_softc; | |
468 | 460 | |||
469 | ure_reset(un); | 461 | ure_reset(un); | |
470 | } | 462 | } | |
471 | 463 | |||
472 | static void | 464 | static void | |
473 | ure_rtl8152_init(struct usbnet *un) | 465 | ure_rtl8152_init(struct usbnet *un) | |
474 | { | 466 | { | |
475 | uint32_t pwrctrl; | 467 | uint32_t pwrctrl; | |
476 | 468 |
--- src/sys/dev/usb/if_url.c 2022/03/03 05:51:44 1.84
+++ src/sys/dev/usb/if_url.c 2022/03/03 05:52:35 1.85
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_url.c,v 1.84 2022/03/03 05:51:44 riastradh Exp $ */ | 1 | /* $NetBSD: if_url.c,v 1.85 2022/03/03 05:52:35 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.84 2022/03/03 05:51:44 riastradh Exp $"); | 47 | __KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.85 2022/03/03 05:52:35 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 | |
@@ -353,27 +353,27 @@ static int | @@ -353,27 +353,27 @@ static int | |||
353 | url_csr_write_4(struct usbnet *un, int reg, int aval) | 353 | url_csr_write_4(struct usbnet *un, int reg, int aval) | |
354 | { | 354 | { | |
355 | uDWord val; | 355 | uDWord val; | |
356 | 356 | |||
357 | DPRINTFN(0x100, | 357 | DPRINTFN(0x100, | |
358 | ("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | 358 | ("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | |
359 | 359 | |||
360 | USETDW(val, aval); | 360 | USETDW(val, aval); | |
361 | 361 | |||
362 | return url_mem(un, URL_CMD_WRITEMEM, reg, &val, 4) ? -1 : 0; | 362 | return url_mem(un, URL_CMD_WRITEMEM, reg, &val, 4) ? -1 : 0; | |
363 | } | 363 | } | |
364 | 364 | |||
365 | static int | 365 | static int | |
366 | url_init_locked(struct ifnet *ifp) | 366 | url_uno_init(struct ifnet *ifp) | |
367 | { | 367 | { | |
368 | struct usbnet * const un = ifp->if_softc; | 368 | struct usbnet * const un = ifp->if_softc; | |
369 | const u_char *eaddr; | 369 | const u_char *eaddr; | |
370 | int i; | 370 | int i; | |
371 | 371 | |||
372 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | 372 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | |
373 | 373 | |||
374 | usbnet_isowned_core(un); | 374 | usbnet_isowned_core(un); | |
375 | 375 | |||
376 | if (usbnet_isdying(un)) | 376 | if (usbnet_isdying(un)) | |
377 | return EIO; | 377 | return EIO; | |
378 | 378 | |||
379 | /* Cancel pending I/O and free all TX/RX buffers */ | 379 | /* Cancel pending I/O and free all TX/RX buffers */ | |
@@ -391,34 +391,26 @@ url_init_locked(struct ifnet *ifp) | @@ -391,34 +391,26 @@ url_init_locked(struct ifnet *ifp) | |||
391 | 391 | |||
392 | /* Init receive control register */ | 392 | /* Init receive control register */ | |
393 | URL_SETBIT2(un, URL_RCR, URL_RCR_TAIL | URL_RCR_AD | URL_RCR_AB); | 393 | URL_SETBIT2(un, URL_RCR, URL_RCR_TAIL | URL_RCR_AD | URL_RCR_AB); | |
394 | 394 | |||
395 | /* Accept multicast frame or run promisc. mode */ | 395 | /* Accept multicast frame or run promisc. mode */ | |
396 | url_rcvfilt_locked(un); | 396 | url_rcvfilt_locked(un); | |
397 | 397 | |||
398 | /* Enable RX and TX */ | 398 | /* Enable RX and TX */ | |
399 | URL_SETBIT(un, URL_CR, URL_CR_TE | URL_CR_RE); | 399 | URL_SETBIT(un, URL_CR, URL_CR_TE | URL_CR_RE); | |
400 | 400 | |||
401 | return usbnet_init_rx_tx(un); | 401 | return usbnet_init_rx_tx(un); | |
402 | } | 402 | } | |
403 | 403 | |||
404 | static int | |||
405 | url_uno_init(struct ifnet *ifp) | |||
406 | { | |||
407 | int ret = url_init_locked(ifp); | |||
408 | ||||
409 | return ret; | |||
410 | } | |||
411 | ||||
412 | static void | 404 | static void | |
413 | url_reset(struct usbnet *un) | 405 | url_reset(struct usbnet *un) | |
414 | { | 406 | { | |
415 | int i; | 407 | int i; | |
416 | 408 | |||
417 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | 409 | DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); | |
418 | 410 | |||
419 | if (usbnet_isdying(un)) | 411 | if (usbnet_isdying(un)) | |
420 | return; | 412 | return; | |
421 | 413 | |||
422 | URL_SETBIT(un, URL_CR, URL_CR_SOFT_RST); | 414 | URL_SETBIT(un, URL_CR, URL_CR_SOFT_RST); | |
423 | 415 | |||
424 | for (i = 0; i < URL_TX_TIMEOUT; i++) { | 416 | for (i = 0; i < URL_TX_TIMEOUT; i++) { |