Thu Mar 3 05:53:04 2022 UTC ()
usbnet drivers: Omit needless uno_mcast locked subroutines.

uno_mcast is now called with the core lock already held so there is
no need for a separate locked subroutine.


(riastradh)
diff -r1.178 -r1.179 src/sys/dev/usb/if_aue.c
diff -r1.140 -r1.141 src/sys/dev/usb/if_axe.c
diff -r1.82 -r1.83 src/sys/dev/usb/if_axen.c
diff -r1.98 -r1.99 src/sys/dev/usb/if_cue.c
diff -r1.111 -r1.112 src/sys/dev/usb/if_kue.c
diff -r1.14 -r1.15 src/sys/dev/usb/if_mos.c
diff -r1.71 -r1.72 src/sys/dev/usb/if_mue.c
diff -r1.80 -r1.81 src/sys/dev/usb/if_smsc.c
diff -r1.85 -r1.86 src/sys/dev/usb/if_udav.c
diff -r1.47 -r1.48 src/sys/dev/usb/if_ure.c
diff -r1.86 -r1.87 src/sys/dev/usb/if_url.c

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

--- src/sys/dev/usb/if_aue.c 2022/03/03 05:52:55 1.178
+++ src/sys/dev/usb/if_aue.c 2022/03/03 05:53:04 1.179
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_aue.c,v 1.178 2022/03/03 05:52:55 riastradh Exp $ */ 1/* $NetBSD: if_aue.c,v 1.179 2022/03/03 05:53:04 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.178 2022/03/03 05:52:55 riastradh Exp $"); 79__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.179 2022/03/03 05:53:04 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
@@ -601,30 +601,30 @@ aue_crc(void *addrv) @@ -601,30 +601,30 @@ aue_crc(void *addrv)
601 601
602 /* Compute CRC for the address value. */ 602 /* Compute CRC for the address value. */
603 crc = 0xFFFFFFFF; /* initial value */ 603 crc = 0xFFFFFFFF; /* initial value */
604 604
605 for (idx = 0; idx < 6; idx++) { 605 for (idx = 0; idx < 6; idx++) {
606 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) 606 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1)
607 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? AUE_POLY : 0); 607 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? AUE_POLY : 0);
608 } 608 }
609 609
610 return crc & ((1 << AUE_BITS) - 1); 610 return crc & ((1 << AUE_BITS) - 1);
611} 611}
612 612
613static void 613static void
614aue_setiff_locked(struct usbnet *un) 614aue_uno_mcast(struct ifnet *ifp)
615{ 615{
 616 struct usbnet * const un = ifp->if_softc;
616 struct aue_softc * const sc = usbnet_softc(un); 617 struct aue_softc * const sc = usbnet_softc(un);
617 struct ifnet * const ifp = usbnet_ifp(un); 
618 struct ethercom * ec = usbnet_ec(un); 618 struct ethercom * ec = usbnet_ec(un);
619 struct ether_multi *enm; 619 struct ether_multi *enm;
620 struct ether_multistep step; 620 struct ether_multistep step;
621 uint32_t h = 0, i; 621 uint32_t h = 0, i;
622 uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 622 uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
623 623
624 AUEHIST_FUNC(); 624 AUEHIST_FUNC();
625 AUEHIST_CALLARGSN(5, "aue%jd: enter", device_unit(un->un_dev), 0, 0, 0); 625 AUEHIST_CALLARGSN(5, "aue%jd: enter", device_unit(un->un_dev), 0, 0, 0);
626 626
627 usbnet_isowned_core(un); 627 usbnet_isowned_core(un);
628 628
629 if (ifp->if_flags & IFF_PROMISC) { 629 if (ifp->if_flags & IFF_PROMISC) {
630allmulti: 630allmulti:
@@ -978,51 +978,39 @@ aue_uno_init(struct ifnet *ifp) @@ -978,51 +978,39 @@ aue_uno_init(struct ifnet *ifp)
978 eaddr = CLLADDR(ifp->if_sadl); 978 eaddr = CLLADDR(ifp->if_sadl);
979 for (i = 0; i < ETHER_ADDR_LEN; i++) 979 for (i = 0; i < ETHER_ADDR_LEN; i++)
980 aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]); 980 aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]);
981 981
982 /* If we want promiscuous mode, set the allframes bit. */ 982 /* If we want promiscuous mode, set the allframes bit. */
983 if (ifp->if_flags & IFF_PROMISC) 983 if (ifp->if_flags & IFF_PROMISC)
984 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); 984 AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
985 else 985 else
986 AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); 986 AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
987 987
988 rv = usbnet_init_rx_tx(un); 988 rv = usbnet_init_rx_tx(un);
989 989
990 /* Load the multicast filter. */ 990 /* Load the multicast filter. */
991 aue_setiff_locked(un); 991 aue_uno_mcast(ifp);
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
1003static void 1003static void
1004aue_uno_mcast(struct ifnet *ifp) 
1005{ 
1006 
1007 AUEHIST_FUNC(); 
1008 AUEHIST_CALLARGSN(5, "aue%jd: enter", 
1009 device_unit(((struct usbnet *)(ifp->if_softc))->un_dev), 
1010 0, 0, 0); 
1011 
1012 aue_setiff_locked(ifp); 
1013} 
1014 
1015static void 
1016aue_uno_stop(struct ifnet *ifp, int disable) 1004aue_uno_stop(struct ifnet *ifp, int disable)
1017{ 1005{
1018 struct usbnet * const un = ifp->if_softc; 1006 struct usbnet * const un = ifp->if_softc;
1019 struct aue_softc * const sc = usbnet_softc(un); 1007 struct aue_softc * const sc = usbnet_softc(un);
1020 1008
1021 AUEHIST_FUNC(); 1009 AUEHIST_FUNC();
1022 AUEHIST_CALLARGSN(5, "aue%jd: enter", device_unit(un->un_dev), 0, 0, 0); 1010 AUEHIST_CALLARGSN(5, "aue%jd: enter", device_unit(un->un_dev), 0, 0, 0);
1023 1011
1024 aue_csr_write_1(sc, AUE_CTL0, 0); 1012 aue_csr_write_1(sc, AUE_CTL0, 0);
1025 aue_csr_write_1(sc, AUE_CTL1, 0); 1013 aue_csr_write_1(sc, AUE_CTL1, 0);
1026 aue_reset(sc); 1014 aue_reset(sc);
1027} 1015}
1028 1016

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

--- src/sys/dev/usb/if_axe.c 2022/03/03 05:52:46 1.140
+++ src/sys/dev/usb/if_axe.c 2022/03/03 05:53:04 1.141
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_axe.c,v 1.140 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_axe.c,v 1.141 2022/03/03 05:53:04 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.140 2022/03/03 05:52:46 riastradh Exp $"); 90__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.141 2022/03/03 05:53:04 riastradh Exp $");
91 91
92#ifdef _KERNEL_OPT 92#ifdef _KERNEL_OPT
93#include "opt_usb.h" 93#include "opt_usb.h"
94#include "opt_net_mpsafe.h" 94#include "opt_net_mpsafe.h"
95#endif 95#endif
96 96
97#include <sys/param.h> 97#include <sys/param.h>
98 98
99#include <dev/usb/usbnet.h> 99#include <dev/usb/usbnet.h>
100#include <dev/usb/usbhist.h> 100#include <dev/usb/usbhist.h>
101#include <dev/usb/if_axereg.h> 101#include <dev/usb/if_axereg.h>
102 102
103struct axe_type { 103struct axe_type {
@@ -416,31 +416,31 @@ axe_uno_mii_statchg(struct ifnet *ifp) @@ -416,31 +416,31 @@ axe_uno_mii_statchg(struct ifnet *ifp)
416 case IFM_10_T: 416 case IFM_10_T:
417 usbnet_set_link(un, true); 417 usbnet_set_link(un, true);
418 break; 418 break;
419 } 419 }
420 } 420 }
421 421
422 DPRINTF("val=%#jx", val, 0, 0, 0); 422 DPRINTF("val=%#jx", val, 0, 0, 0);
423 err = axe_cmd(sc, AXE_CMD_WRITE_MEDIA, 0, val, NULL); 423 err = axe_cmd(sc, AXE_CMD_WRITE_MEDIA, 0, val, NULL);
424 if (err) 424 if (err)
425 device_printf(un->un_dev, "media change failed\n"); 425 device_printf(un->un_dev, "media change failed\n");
426} 426}
427 427
428static void 428static void
429axe_rcvfilt_locked(struct usbnet *un) 429axe_uno_mcast(struct ifnet *ifp)
430{ 430{
431 AXEHIST_FUNC(); AXEHIST_CALLED(); 431 AXEHIST_FUNC(); AXEHIST_CALLED();
 432 struct usbnet * const un = ifp->if_softc;
432 struct axe_softc * const sc = usbnet_softc(un); 433 struct axe_softc * const sc = usbnet_softc(un);
433 struct ifnet * const ifp = usbnet_ifp(un); 
434 struct ethercom *ec = usbnet_ec(un); 434 struct ethercom *ec = usbnet_ec(un);
435 struct ether_multi *enm; 435 struct ether_multi *enm;
436 struct ether_multistep step; 436 struct ether_multistep step;
437 uint16_t rxmode; 437 uint16_t rxmode;
438 uint32_t h = 0; 438 uint32_t h = 0;
439 uint8_t mchash[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 439 uint8_t mchash[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
440 440
441 if (usbnet_isdying(un)) 441 if (usbnet_isdying(un))
442 return; 442 return;
443 443
444 if (axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode)) { 444 if (axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode)) {
445 device_printf(un->un_dev, "can't read rxmode"); 445 device_printf(un->un_dev, "can't read rxmode");
446 return; 446 return;
@@ -1291,39 +1291,31 @@ axe_uno_init(struct ifnet *ifp) @@ -1291,39 +1291,31 @@ axe_uno_init(struct ifnet *ifp)
1291 if (un->un_udev->ud_speed == USB_SPEED_HIGH) { 1291 if (un->un_udev->ud_speed == USB_SPEED_HIGH) {
1292 /* Largest possible USB buffer size for AX88178 */ 1292 /* Largest possible USB buffer size for AX88178 */
1293 } 1293 }
1294#endif 1294#endif
1295 rxmode |= AXE_178_RXCMD_MFB_16384; 1295 rxmode |= AXE_178_RXCMD_MFB_16384;
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_uno_mcast(ifp);
1305 1305
1306 return usbnet_init_rx_tx(un); 1306 return usbnet_init_rx_tx(un);
1307} 1307}
1308 1308
1309static void 1309static void
1310axe_uno_mcast(struct ifnet *ifp) 
1311{ 
1312 struct usbnet * const un = ifp->if_softc; 
1313 
1314 axe_rcvfilt_locked(un); 
1315} 
1316 
1317static void 
1318axe_uno_stop(struct ifnet *ifp, int disable) 1310axe_uno_stop(struct ifnet *ifp, int disable)
1319{ 1311{
1320 struct usbnet * const un = ifp->if_softc; 1312 struct usbnet * const un = ifp->if_softc;
1321 1313
1322 axe_reset(un); 1314 axe_reset(un);
1323} 1315}
1324 1316
1325#ifdef _MODULE 1317#ifdef _MODULE
1326#include "ioconf.c" 1318#include "ioconf.c"
1327#endif 1319#endif
1328 1320
1329USBNET_MODULE(axe) 1321USBNET_MODULE(axe)

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

--- src/sys/dev/usb/if_axen.c 2022/03/03 05:52:46 1.82
+++ src/sys/dev/usb/if_axen.c 2022/03/03 05:53:04 1.83
@@ -1,39 +1,39 @@ @@ -1,39 +1,39 @@
1/* $NetBSD: if_axen.c,v 1.82 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_axen.c,v 1.83 2022/03/03 05:53:04 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.82 2022/03/03 05:52:46 riastradh Exp $"); 26__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.83 2022/03/03 05:53:04 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>
@@ -215,29 +215,29 @@ axen_uno_mii_statchg(struct ifnet *ifp) @@ -215,29 +215,29 @@ axen_uno_mii_statchg(struct ifnet *ifp)
215 case IFM_10_T: 215 case IFM_10_T:
216 /* doesn't need to be handled */ 216 /* doesn't need to be handled */
217 break; 217 break;
218 } 218 }
219 219
220 DPRINTF(("%s: val=%#x\n", __func__, val)); 220 DPRINTF(("%s: val=%#x\n", __func__, val));
221 wval = htole16(val); 221 wval = htole16(val);
222 err = axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MEDIUM_STATUS, &wval); 222 err = axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MEDIUM_STATUS, &wval);
223 if (err) 223 if (err)
224 aprint_error_dev(un->un_dev, "media change failed\n"); 224 aprint_error_dev(un->un_dev, "media change failed\n");
225} 225}
226 226
227static void 227static void
228axen_setiff_locked(struct usbnet *un) 228axen_uno_mcast(struct ifnet *ifp)
229{ 229{
230 struct ifnet * const ifp = usbnet_ifp(un); 230 struct usbnet * const un = ifp->if_softc;
231 struct ethercom *ec = usbnet_ec(un); 231 struct ethercom *ec = usbnet_ec(un);
232 struct ether_multi *enm; 232 struct ether_multi *enm;
233 struct ether_multistep step; 233 struct ether_multistep step;
234 uint32_t h = 0; 234 uint32_t h = 0;
235 uint16_t rxmode; 235 uint16_t rxmode;
236 uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 236 uint8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
237 uint16_t wval; 237 uint16_t wval;
238 238
239 if (usbnet_isdying(un)) 239 if (usbnet_isdying(un))
240 return; 240 return;
241 241
242 usbnet_isowned_core(un); 242 usbnet_isowned_core(un);
243 243
@@ -559,34 +559,26 @@ axen_uno_ioctl(struct ifnet *ifp, u_long @@ -559,34 +559,26 @@ axen_uno_ioctl(struct ifnet *ifp, u_long
559 switch (cmd) { 559 switch (cmd) {
560 case SIOCSIFCAP: 560 case SIOCSIFCAP:
561 axen_setoe_locked(un); 561 axen_setoe_locked(un);
562 break; 562 break;
563 default: 563 default:
564 break; 564 break;
565 } 565 }
566 566
567 usbnet_unlock_core(un); 567 usbnet_unlock_core(un);
568 568
569 return 0; 569 return 0;
570} 570}
571 571
572static void 
573axen_uno_mcast(struct ifnet *ifp) 
574{ 
575 struct usbnet * const un = ifp->if_softc; 
576 
577 axen_setiff_locked(un); 
578} 
579 
580static int 572static int
581axen_match(device_t parent, cfdata_t match, void *aux) 573axen_match(device_t parent, cfdata_t match, void *aux)
582{ 574{
583 struct usb_attach_arg *uaa = aux; 575 struct usb_attach_arg *uaa = aux;
584 576
585 return axen_lookup(uaa->uaa_vendor, uaa->uaa_product) != NULL ? 577 return axen_lookup(uaa->uaa_vendor, uaa->uaa_product) != NULL ?
586 UMATCH_VENDOR_PRODUCT : UMATCH_NONE; 578 UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
587} 579}
588 580
589static void 581static void
590axen_attach(device_t parent, device_t self, void *aux) 582axen_attach(device_t parent, device_t self, void *aux)
591{ 583{
592 USBNET_MII_DECL_DEFAULT(unm); 584 USBNET_MII_DECL_DEFAULT(unm);
@@ -906,27 +898,27 @@ axen_uno_init(struct ifnet *ifp) @@ -906,27 +898,27 @@ axen_uno_init(struct ifnet *ifp)
906 usbnet_stop(un, ifp, 1); 898 usbnet_stop(un, ifp, 1);
907 899
908 /* Reset the ethernet interface. */ 900 /* Reset the ethernet interface. */
909 axen_reset(un); 901 axen_reset(un);
910 902
911 /* XXX: ? */ 903 /* XXX: ? */
912 bval = 0x01; 904 bval = 0x01;
913 axen_cmd(un, AXEN_CMD_MAC_WRITE, 1, AXEN_UNK_28, &bval); 905 axen_cmd(un, AXEN_CMD_MAC_WRITE, 1, AXEN_UNK_28, &bval);
914 906
915 /* Configure offloading engine. */ 907 /* Configure offloading engine. */
916 axen_setoe_locked(un); 908 axen_setoe_locked(un);
917 909
918 /* Program promiscuous mode and multicast filters. */ 910 /* Program promiscuous mode and multicast filters. */
919 axen_setiff_locked(un); 911 axen_uno_mcast(ifp);
920 912
921 /* Enable receiver, set RX mode */ 913 /* Enable receiver, set RX mode */
922 axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval); 914 axen_cmd(un, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval);
923 rxmode = le16toh(wval); 915 rxmode = le16toh(wval);
924 rxmode |= AXEN_RXCTL_START; 916 rxmode |= AXEN_RXCTL_START;
925 wval = htole16(rxmode); 917 wval = htole16(rxmode);
926 axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval); 918 axen_cmd(un, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval);
927 919
928 return usbnet_init_rx_tx(un); 920 return usbnet_init_rx_tx(un);
929} 921}
930 922
931static void 923static void
932axen_uno_stop(struct ifnet *ifp, int disable) 924axen_uno_stop(struct ifnet *ifp, int disable)

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

--- src/sys/dev/usb/if_cue.c 2022/03/03 05:52:46 1.98
+++ src/sys/dev/usb/if_cue.c 2022/03/03 05:53:04 1.99
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_cue.c,v 1.98 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_cue.c,v 1.99 2022/03/03 05:53:04 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.98 2022/03/03 05:52:46 riastradh Exp $"); 60__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.99 2022/03/03 05:53:04 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>
@@ -347,31 +347,31 @@ cue_crc(const char *addr) @@ -347,31 +347,31 @@ cue_crc(const char *addr)
347 347
348 /* Compute CRC for the address value. */ 348 /* Compute CRC for the address value. */
349 crc = 0xFFFFFFFF; /* initial value */ 349 crc = 0xFFFFFFFF; /* initial value */
350 350
351 for (idx = 0; idx < 6; idx++) { 351 for (idx = 0; idx < 6; idx++) {
352 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) 352 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1)
353 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? CUE_POLY : 0); 353 crc = (crc >> 1) ^ (((crc ^ data) & 1) ? CUE_POLY : 0);
354 } 354 }
355 355
356 return crc & ((1 << CUE_BITS) - 1); 356 return crc & ((1 << CUE_BITS) - 1);
357} 357}
358 358
359static void 359static void
360cue_setiff_locked(struct usbnet *un) 360cue_uno_mcast(struct ifnet *ifp)
361{ 361{
 362 struct usbnet *un = ifp->if_softc;
362 struct cue_softc *sc = usbnet_softc(un); 363 struct cue_softc *sc = usbnet_softc(un);
363 struct ethercom *ec = usbnet_ec(un); 364 struct ethercom *ec = usbnet_ec(un);
364 struct ifnet *ifp = usbnet_ifp(un); 
365 struct ether_multi *enm; 365 struct ether_multi *enm;
366 struct ether_multistep step; 366 struct ether_multistep step;
367 uint32_t h, i; 367 uint32_t h, i;
368 368
369 DPRINTFN(2,("%s: cue_setiff if_flags=%#x\n", 369 DPRINTFN(2,("%s: cue_setiff if_flags=%#x\n",
370 device_xname(un->un_dev), ifp->if_flags)); 370 device_xname(un->un_dev), ifp->if_flags));
371 371
372 if (ifp->if_flags & IFF_PROMISC) { 372 if (ifp->if_flags & IFF_PROMISC) {
373allmulti: 373allmulti:
374 ifp->if_flags |= IFF_ALLMULTI; 374 ifp->if_flags |= IFF_ALLMULTI;
375 for (i = 0; i < CUE_MCAST_TABLE_LEN; i++) 375 for (i = 0; i < CUE_MCAST_TABLE_LEN; i++)
376 sc->cue_mctab[i] = 0xFF; 376 sc->cue_mctab[i] = 0xFF;
377 cue_mem(un, CUE_CMD_WRITESRAM, CUE_MCAST_TABLE_ADDR, 377 cue_mem(un, CUE_CMD_WRITESRAM, CUE_MCAST_TABLE_ADDR,
@@ -638,53 +638,45 @@ cue_uno_init(struct ifnet *ifp) @@ -638,53 +638,45 @@ cue_uno_init(struct ifnet *ifp)
638 638
639 eaddr = CLLADDR(ifp->if_sadl); 639 eaddr = CLLADDR(ifp->if_sadl);
640 /* Set MAC address */ 640 /* Set MAC address */
641 for (i = 0; i < ETHER_ADDR_LEN; i++) 641 for (i = 0; i < ETHER_ADDR_LEN; i++)
642 cue_csr_write_1(un, CUE_PAR0 - i, eaddr[i]); 642 cue_csr_write_1(un, CUE_PAR0 - i, eaddr[i]);
643 643
644 /* Enable RX logic. */ 644 /* Enable RX logic. */
645 ctl = CUE_ETHCTL_RX_ON | CUE_ETHCTL_MCAST_ON; 645 ctl = CUE_ETHCTL_RX_ON | CUE_ETHCTL_MCAST_ON;
646 if (ifp->if_flags & IFF_PROMISC) 646 if (ifp->if_flags & IFF_PROMISC)
647 ctl |= CUE_ETHCTL_PROMISC; 647 ctl |= CUE_ETHCTL_PROMISC;
648 cue_csr_write_1(un, CUE_ETHCTL, ctl); 648 cue_csr_write_1(un, CUE_ETHCTL, ctl);
649 649
650 /* Load the multicast filter. */ 650 /* Load the multicast filter. */
651 cue_setiff_locked(un); 651 cue_uno_mcast(ifp);
652 652
653 /* 653 /*
654 * Set the number of RX and TX buffers that we want 654 * Set the number of RX and TX buffers that we want
655 * to reserve inside the ASIC. 655 * to reserve inside the ASIC.
656 */ 656 */
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
670static void 
671cue_uno_mcast(struct ifnet *ifp) 
672{ 
673 struct usbnet * const un = ifp->if_softc; 
674 
675 cue_setiff_locked(un); 
676} 
677 
678/* Stop and reset the adapter. */ 670/* Stop and reset the adapter. */
679static void 671static void
680cue_uno_stop(struct ifnet *ifp, int disable) 672cue_uno_stop(struct ifnet *ifp, int disable)
681{ 673{
682 struct usbnet * const un = ifp->if_softc; 674 struct usbnet * const un = ifp->if_softc;
683 675
684 DPRINTFN(10,("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 676 DPRINTFN(10,("%s: %s: enter\n", device_xname(un->un_dev), __func__));
685 677
686 cue_csr_write_1(un, CUE_ETHCTL, 0); 678 cue_csr_write_1(un, CUE_ETHCTL, 0);
687 cue_reset(un); 679 cue_reset(un);
688} 680}
689 681
690#ifdef _MODULE 682#ifdef _MODULE

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

--- src/sys/dev/usb/if_kue.c 2022/03/03 05:52:46 1.111
+++ src/sys/dev/usb/if_kue.c 2022/03/03 05:53:04 1.112
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_kue.c,v 1.111 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_kue.c,v 1.112 2022/03/03 05:53:04 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.111 2022/03/03 05:52:46 riastradh Exp $"); 74__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.112 2022/03/03 05:53:04 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>
@@ -308,31 +308,31 @@ kue_load_fw(struct usbnet *un) @@ -308,31 +308,31 @@ kue_load_fw(struct usbnet *un)
308 * dependent on the revision data. 308 * dependent on the revision data.
309 */ 309 */
310 (void)usbd_reload_device_desc(un->un_udev); 310 (void)usbd_reload_device_desc(un->un_udev);
311 311
312 DPRINTFN(1,("%s: %s: done\n", device_xname(un->un_dev), __func__)); 312 DPRINTFN(1,("%s: %s: done\n", device_xname(un->un_dev), __func__));
313 313
314 /* Reset the adapter. */ 314 /* Reset the adapter. */
315 kue_reset(un); 315 kue_reset(un);
316 316
317 return 0; 317 return 0;
318} 318}
319 319
320static void 320static void
321kue_setiff_locked(struct usbnet *un) 321kue_uno_mcast(struct ifnet *ifp)
322{ 322{
 323 struct usbnet * un = ifp->if_softc;
323 struct ethercom * ec = usbnet_ec(un); 324 struct ethercom * ec = usbnet_ec(un);
324 struct kue_softc * sc = usbnet_softc(un); 325 struct kue_softc * sc = usbnet_softc(un);
325 struct ifnet * const ifp = usbnet_ifp(un); 
326 struct ether_multi *enm; 326 struct ether_multi *enm;
327 struct ether_multistep step; 327 struct ether_multistep step;
328 int i; 328 int i;
329 329
330 DPRINTFN(5,("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 330 DPRINTFN(5,("%s: %s: enter\n", device_xname(un->un_dev), __func__));
331 331
332 /* If we want promiscuous mode, set the allframes bit. */ 332 /* If we want promiscuous mode, set the allframes bit. */
333 if (ifp->if_flags & IFF_PROMISC) 333 if (ifp->if_flags & IFF_PROMISC)
334 sc->kue_rxfilt |= KUE_RXFILT_PROMISC; 334 sc->kue_rxfilt |= KUE_RXFILT_PROMISC;
335 else 335 else
336 sc->kue_rxfilt &= ~KUE_RXFILT_PROMISC; 336 sc->kue_rxfilt &= ~KUE_RXFILT_PROMISC;
337 337
338 if (ifp->if_flags & IFF_PROMISC) { 338 if (ifp->if_flags & IFF_PROMISC) {
@@ -612,31 +612,23 @@ kue_uno_init(struct ifnet *ifp) @@ -612,31 +612,23 @@ kue_uno_init(struct ifnet *ifp)
612 sc->kue_rxfilt = KUE_RXFILT_UNICAST | KUE_RXFILT_BROADCAST; 612 sc->kue_rxfilt = KUE_RXFILT_UNICAST | KUE_RXFILT_BROADCAST;
613 613
614 /* I'm not sure how to tune these. */ 614 /* I'm not sure how to tune these. */
615#if 0 615#if 0
616 /* 616 /*
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_uno_mcast(ifp);
626 626
627 return usbnet_init_rx_tx(un); 627 return usbnet_init_rx_tx(un);
628} 628}
629 629
630static void 
631kue_uno_mcast(struct ifnet *ifp) 
632{ 
633 struct usbnet * const un = ifp->if_softc; 
634 
635 kue_setiff_locked(un); 
636} 
637 
638#ifdef _MODULE 630#ifdef _MODULE
639#include "ioconf.c" 631#include "ioconf.c"
640#endif 632#endif
641 633
642USBNET_MODULE(kue) 634USBNET_MODULE(kue)

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

--- src/sys/dev/usb/if_mos.c 2022/03/03 05:52:46 1.14
+++ src/sys/dev/usb/if_mos.c 2022/03/03 05:53:04 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_mos.c,v 1.14 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_mos.c,v 1.15 2022/03/03 05:53:04 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.14 2022/03/03 05:52:46 riastradh Exp $"); 75__KERNEL_RCSID(0, "$NetBSD: if_mos.c,v 1.15 2022/03/03 05:53:04 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
@@ -448,29 +448,29 @@ mos_uno_mii_statchg(struct ifnet *ifp) @@ -448,29 +448,29 @@ mos_uno_mii_statchg(struct ifnet *ifp)
448 } 448 }
449 usbnet_set_link(un, true); 449 usbnet_set_link(un, true);
450 } 450 }
451 451
452 /* re-enable TX, RX */ 452 /* re-enable TX, RX */
453 val |= (MOS_CTL_TX_ENB | MOS_CTL_RX_ENB); 453 val |= (MOS_CTL_TX_ENB | MOS_CTL_RX_ENB);
454 err = mos_reg_write_1(un, MOS_CTL, val); 454 err = mos_reg_write_1(un, MOS_CTL, val);
455 455
456 if (err) 456 if (err)
457 aprint_error_dev(un->un_dev, "media change failed\n"); 457 aprint_error_dev(un->un_dev, "media change failed\n");
458} 458}
459 459
460static void 460static void
461mos_rcvfilt_locked(struct usbnet *un) 461mos_uno_mcast(struct ifnet *ifp)
462{ 462{
463 struct ifnet *ifp = usbnet_ifp(un); 463 struct usbnet *un = ifp->if_softc;
464 struct ethercom *ec = usbnet_ec(un); 464 struct ethercom *ec = usbnet_ec(un);
465 struct ether_multi *enm; 465 struct ether_multi *enm;
466 struct ether_multistep step; 466 struct ether_multistep step;
467 u_int32_t h = 0; 467 u_int32_t h = 0;
468 u_int8_t rxmode, mchash[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 468 u_int8_t rxmode, mchash[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
469 469
470 if (usbnet_isdying(un)) 470 if (usbnet_isdying(un))
471 return; 471 return;
472 472
473 rxmode = mos_reg_read_1(un, MOS_CTL); 473 rxmode = mos_reg_read_1(un, MOS_CTL);
474 rxmode &= ~(MOS_CTL_ALLMULTI | MOS_CTL_RX_PROMISC); 474 rxmode &= ~(MOS_CTL_ALLMULTI | MOS_CTL_RX_PROMISC);
475 475
476 ETHER_LOCK(ec); 476 ETHER_LOCK(ec);
@@ -738,39 +738,31 @@ mos_uno_init(struct ifnet *ifp) @@ -738,39 +738,31 @@ mos_uno_init(struct ifnet *ifp)
738 /* Reset the ethernet interface. */ 738 /* Reset the ethernet interface. */
739 mos_reset(un); 739 mos_reset(un);
740 740
741 /* Write MAC address. */ 741 /* Write MAC address. */
742 mos_writemac(un); 742 mos_writemac(un);
743 743
744 /* Read and set transmitter IPG values */ 744 /* Read and set transmitter IPG values */
745 ipgs[0] = mos_reg_read_1(un, MOS_IPG0); 745 ipgs[0] = mos_reg_read_1(un, MOS_IPG0);
746 ipgs[1] = mos_reg_read_1(un, MOS_IPG1); 746 ipgs[1] = mos_reg_read_1(un, MOS_IPG1);
747 mos_reg_write_1(un, MOS_IPG0, ipgs[0]); 747 mos_reg_write_1(un, MOS_IPG0, ipgs[0]);
748 mos_reg_write_1(un, MOS_IPG1, ipgs[1]); 748 mos_reg_write_1(un, MOS_IPG1, ipgs[1]);
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_uno_mcast(ifp);
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
762static void 
763mos_uno_mcast(struct ifnet *ifp) 
764{ 
765 struct usbnet * const un = ifp->if_softc; 
766 
767 mos_rcvfilt_locked(un); 
768} 
769 
770void 762void
771mos_uno_stop(struct ifnet *ifp, int disable) 763mos_uno_stop(struct ifnet *ifp, int disable)
772{ 764{
773 struct usbnet * const un = ifp->if_softc; 765 struct usbnet * const un = ifp->if_softc;
774 766
775 mos_reset(un); 767 mos_reset(un);
776} 768}

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

--- src/sys/dev/usb/if_mue.c 2022/03/03 05:52:46 1.71
+++ src/sys/dev/usb/if_mue.c 2022/03/03 05:53:04 1.72
@@ -1,36 +1,36 @@ @@ -1,36 +1,36 @@
1/* $NetBSD: if_mue.c,v 1.71 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_mue.c,v 1.72 2022/03/03 05:53:04 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.71 2022/03/03 05:52:46 riastradh Exp $"); 23__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.72 2022/03/03 05:53:04 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
@@ -82,34 +82,33 @@ static void mue_attach(device_t, device_ @@ -82,34 +82,33 @@ static void mue_attach(device_t, device_
82static uint32_t mue_csr_read(struct usbnet *, uint32_t); 82static uint32_t mue_csr_read(struct usbnet *, uint32_t);
83static int mue_csr_write(struct usbnet *, uint32_t, uint32_t); 83static int mue_csr_write(struct usbnet *, uint32_t, uint32_t);
84static int mue_wait_for_bits(struct usbnet *, uint32_t, uint32_t, 84static int mue_wait_for_bits(struct usbnet *, uint32_t, uint32_t,
85 uint32_t, uint32_t); 85 uint32_t, uint32_t);
86static uint8_t mue_eeprom_getbyte(struct usbnet *, int, uint8_t *); 86static uint8_t mue_eeprom_getbyte(struct usbnet *, int, uint8_t *);
87static bool mue_eeprom_present(struct usbnet *); 87static bool mue_eeprom_present(struct usbnet *);
88static void mue_dataport_write(struct usbnet *, uint32_t, uint32_t, 88static void mue_dataport_write(struct usbnet *, uint32_t, uint32_t,
89 uint32_t, uint32_t *); 89 uint32_t, uint32_t *);
90static void mue_init_ltm(struct usbnet *); 90static void mue_init_ltm(struct usbnet *);
91static int mue_chip_init(struct usbnet *); 91static int mue_chip_init(struct usbnet *);
92static void mue_set_macaddr(struct usbnet *); 92static void mue_set_macaddr(struct usbnet *);
93static int mue_get_macaddr(struct usbnet *, prop_dictionary_t); 93static int mue_get_macaddr(struct usbnet *, prop_dictionary_t);
94static int mue_prepare_tso(struct usbnet *, struct mbuf *); 94static int mue_prepare_tso(struct usbnet *, struct mbuf *);
95static void mue_setiff_locked(struct usbnet *); 95static void mue_uno_mcast(struct ifnet *);
96static void mue_sethwcsum_locked(struct usbnet *); 96static void mue_sethwcsum_locked(struct usbnet *);
97static void mue_setmtu_locked(struct usbnet *); 97static void mue_setmtu_locked(struct usbnet *);
98static void mue_reset(struct usbnet *); 98static void mue_reset(struct usbnet *);
99 99
100static void mue_uno_stop(struct ifnet *, int); 100static void mue_uno_stop(struct ifnet *, int);
101static int mue_uno_ioctl(struct ifnet *, u_long, void *); 101static int mue_uno_ioctl(struct ifnet *, u_long, void *);
102static void mue_uno_mcast(struct ifnet *); 
103static int mue_uno_mii_read_reg(struct usbnet *, int, int, uint16_t *); 102static int mue_uno_mii_read_reg(struct usbnet *, int, int, uint16_t *);
104static int mue_uno_mii_write_reg(struct usbnet *, int, int, uint16_t); 103static int mue_uno_mii_write_reg(struct usbnet *, int, int, uint16_t);
105static void mue_uno_mii_statchg(struct ifnet *); 104static void mue_uno_mii_statchg(struct ifnet *);
106static void mue_uno_rx_loop(struct usbnet *, struct usbnet_chain *, 105static void mue_uno_rx_loop(struct usbnet *, struct usbnet_chain *,
107 uint32_t); 106 uint32_t);
108static unsigned mue_uno_tx_prepare(struct usbnet *, struct mbuf *, 107static unsigned mue_uno_tx_prepare(struct usbnet *, struct mbuf *,
109 struct usbnet_chain *); 108 struct usbnet_chain *);
110static int mue_uno_init(struct ifnet *); 109static int mue_uno_init(struct ifnet *);
111 110
112static const struct usbnet_ops mue_ops = { 111static const struct usbnet_ops mue_ops = {
113 .uno_stop = mue_uno_stop, 112 .uno_stop = mue_uno_stop,
114 .uno_ioctl = mue_uno_ioctl, 113 .uno_ioctl = mue_uno_ioctl,
115 .uno_mcast = mue_uno_mcast, 114 .uno_mcast = mue_uno_mcast,
@@ -987,30 +986,30 @@ mue_prepare_tso(struct usbnet *un, struc @@ -987,30 +986,30 @@ mue_prepare_tso(struct usbnet *un, struc
987 sizeof(len), &len); 986 sizeof(len), &len);
988 } else { 987 } else {
989 if (__predict_true(m->m_len >= off + (int)sizeof(*ip6))) { 988 if (__predict_true(m->m_len >= off + (int)sizeof(*ip6))) {
990 ip6 = (void *)(mtod(m, char *) + off); 989 ip6 = (void *)(mtod(m, char *) + off);
991 ip6->ip6_plen = 0; 990 ip6->ip6_plen = 0;
992 } else 991 } else
993 m_copyback(m, off + offsetof(struct ip6_hdr, ip6_plen), 992 m_copyback(m, off + offsetof(struct ip6_hdr, ip6_plen),
994 sizeof(len), &len); 993 sizeof(len), &len);
995 } 994 }
996 return 0; 995 return 0;
997} 996}
998 997
999static void 998static void
1000mue_setiff_locked(struct usbnet *un) 999mue_uno_mcast(struct ifnet *ifp)
1001{ 1000{
 1001 struct usbnet *un = ifp->if_softc;
1002 struct ethercom *ec = usbnet_ec(un); 1002 struct ethercom *ec = usbnet_ec(un);
1003 struct ifnet * const ifp = usbnet_ifp(un); 
1004 const uint8_t *enaddr = CLLADDR(ifp->if_sadl); 1003 const uint8_t *enaddr = CLLADDR(ifp->if_sadl);
1005 struct ether_multi *enm; 1004 struct ether_multi *enm;
1006 struct ether_multistep step; 1005 struct ether_multistep step;
1007 uint32_t pfiltbl[MUE_NUM_ADDR_FILTX][2]; 1006 uint32_t pfiltbl[MUE_NUM_ADDR_FILTX][2];
1008 uint32_t hashtbl[MUE_DP_SEL_VHF_HASH_LEN]; 1007 uint32_t hashtbl[MUE_DP_SEL_VHF_HASH_LEN];
1009 uint32_t reg, rxfilt, h, hireg, loreg; 1008 uint32_t reg, rxfilt, h, hireg, loreg;
1010 size_t i; 1009 size_t i;
1011 1010
1012 if (usbnet_isdying(un)) 1011 if (usbnet_isdying(un))
1013 return; 1012 return;
1014 1013
1015 /* Clear perfect filter and hash tables. */ 1014 /* Clear perfect filter and hash tables. */
1016 memset(pfiltbl, 0, sizeof(pfiltbl)); 1015 memset(pfiltbl, 0, sizeof(pfiltbl));
@@ -1232,27 +1231,27 @@ mue_uno_init(struct ifnet *ifp) @@ -1232,27 +1231,27 @@ mue_uno_init(struct ifnet *ifp)
1232 return EIO; 1231 return EIO;
1233 } 1232 }
1234 1233
1235 /* Cancel pending I/O and free all TX/RX buffers. */ 1234 /* Cancel pending I/O and free all TX/RX buffers. */
1236 if (ifp->if_flags & IFF_RUNNING) 1235 if (ifp->if_flags & IFF_RUNNING)
1237 usbnet_stop(un, ifp, 1); 1236 usbnet_stop(un, ifp, 1);
1238 1237
1239 mue_reset(un); 1238 mue_reset(un);
1240 1239
1241 /* Set MAC address. */ 1240 /* Set MAC address. */
1242 mue_set_macaddr(un); 1241 mue_set_macaddr(un);
1243 1242
1244 /* Load the multicast filter. */ 1243 /* Load the multicast filter. */
1245 mue_setiff_locked(un); 1244 mue_uno_mcast(ifp);
1246 1245
1247 /* TCP/UDP checksum offload engines. */ 1246 /* TCP/UDP checksum offload engines. */
1248 mue_sethwcsum_locked(un); 1247 mue_sethwcsum_locked(un);
1249 1248
1250 /* Set MTU. */ 1249 /* Set MTU. */
1251 mue_setmtu_locked(un); 1250 mue_setmtu_locked(un);
1252 1251
1253 return usbnet_init_rx_tx(un); 1252 return usbnet_init_rx_tx(un);
1254} 1253}
1255 1254
1256static int 1255static int
1257mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data) 1256mue_uno_ioctl(struct ifnet *ifp, u_long cmd, void *data)
1258{ 1257{
@@ -1267,34 +1266,26 @@ mue_uno_ioctl(struct ifnet *ifp, u_long  @@ -1267,34 +1266,26 @@ mue_uno_ioctl(struct ifnet *ifp, u_long
1267 case SIOCSIFMTU: 1266 case SIOCSIFMTU:
1268 mue_setmtu_locked(un); 1267 mue_setmtu_locked(un);
1269 break; 1268 break;
1270 default: 1269 default:
1271 break; 1270 break;
1272 } 1271 }
1273 1272
1274 usbnet_unlock_core(un); 1273 usbnet_unlock_core(un);
1275 1274
1276 return 0; 1275 return 0;
1277} 1276}
1278 1277
1279static void 1278static void
1280mue_uno_mcast(struct ifnet *ifp) 
1281{ 
1282 struct usbnet * const un = ifp->if_softc; 
1283 
1284 mue_setiff_locked(un); 
1285} 
1286 
1287static void 
1288mue_reset(struct usbnet *un) 1279mue_reset(struct usbnet *un)
1289{ 1280{
1290 if (usbnet_isdying(un)) 1281 if (usbnet_isdying(un))
1291 return; 1282 return;
1292 1283
1293 /* Wait a little while for the chip to get its brains in order. */ 1284 /* Wait a little while for the chip to get its brains in order. */
1294 usbd_delay_ms(un->un_udev, 1); 1285 usbd_delay_ms(un->un_udev, 1);
1295 1286
1296// mue_chip_init(un); /* XXX */ 1287// mue_chip_init(un); /* XXX */
1297} 1288}
1298 1289
1299static void 1290static void
1300mue_uno_stop(struct ifnet *ifp, int disable) 1291mue_uno_stop(struct ifnet *ifp, int disable)

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

--- src/sys/dev/usb/if_smsc.c 2022/03/03 05:52:46 1.80
+++ src/sys/dev/usb/if_smsc.c 2022/03/03 05:53:04 1.81
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_smsc.c,v 1.80 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_smsc.c,v 1.81 2022/03/03 05:53:04 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.80 2022/03/03 05:52:46 riastradh Exp $"); 64__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.81 2022/03/03 05:53:04 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"
@@ -401,31 +401,31 @@ smsc_uno_miibus_statchg(struct ifnet *if @@ -401,31 +401,31 @@ smsc_uno_miibus_statchg(struct ifnet *if
401 401
402 if (err) 402 if (err)
403 smsc_warn_printf(un, "media change failed, error %d\n", err); 403 smsc_warn_printf(un, "media change failed, error %d\n", err);
404} 404}
405 405
406static inline uint32_t 406static inline uint32_t
407smsc_hash(uint8_t addr[ETHER_ADDR_LEN]) 407smsc_hash(uint8_t addr[ETHER_ADDR_LEN])
408{ 408{
409 409
410 return (ether_crc32_be(addr, ETHER_ADDR_LEN) >> 26) & 0x3f; 410 return (ether_crc32_be(addr, ETHER_ADDR_LEN) >> 26) & 0x3f;
411} 411}
412 412
413static void 413static void
414smsc_setiff_locked(struct usbnet *un) 414smsc_uno_mcast(struct ifnet *ifp)
415{ 415{
416 USMSCHIST_FUNC(); USMSCHIST_CALLED(); 416 USMSCHIST_FUNC(); USMSCHIST_CALLED();
 417 struct usbnet * const un = ifp->if_softc;
417 struct smsc_softc * const sc = usbnet_softc(un); 418 struct smsc_softc * const sc = usbnet_softc(un);
418 struct ifnet * const ifp = usbnet_ifp(un); 
419 struct ethercom *ec = usbnet_ec(un); 419 struct ethercom *ec = usbnet_ec(un);
420 struct ether_multi *enm; 420 struct ether_multi *enm;
421 struct ether_multistep step; 421 struct ether_multistep step;
422 uint32_t hashtbl[2] = { 0, 0 }; 422 uint32_t hashtbl[2] = { 0, 0 };
423 uint32_t hash; 423 uint32_t hash;
424 424
425 usbnet_isowned_core(un); 425 usbnet_isowned_core(un);
426 426
427 if (usbnet_isdying(un)) 427 if (usbnet_isdying(un))
428 return; 428 return;
429 429
430 if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) { 430 if (ifp->if_flags & (IFF_ALLMULTI | IFF_PROMISC)) {
431allmulti: 431allmulti:
@@ -558,27 +558,27 @@ smsc_uno_init(struct ifnet *ifp) @@ -558,27 +558,27 @@ smsc_uno_init(struct ifnet *ifp)
558 558
559 usbnet_isowned_core(un); 559 usbnet_isowned_core(un);
560 560
561 if (usbnet_isdying(un)) 561 if (usbnet_isdying(un))
562 return EIO; 562 return EIO;
563 563
564 /* Cancel pending I/O */ 564 /* Cancel pending I/O */
565 usbnet_stop(un, ifp, 1); 565 usbnet_stop(un, ifp, 1);
566 566
567 /* Reset the ethernet interface. */ 567 /* Reset the ethernet interface. */
568 smsc_reset(sc); 568 smsc_reset(sc);
569 569
570 /* Load the multicast filter. */ 570 /* Load the multicast filter. */
571 smsc_setiff_locked(un); 571 smsc_uno_mcast(ifp);
572 572
573 /* TCP/UDP checksum offload engines. */ 573 /* TCP/UDP checksum offload engines. */
574 smsc_setoe_locked(un); 574 smsc_setoe_locked(un);
575 575
576 return usbnet_init_rx_tx(un); 576 return usbnet_init_rx_tx(un);
577} 577}
578 578
579static void 579static void
580smsc_uno_stop(struct ifnet *ifp, int disable) 580smsc_uno_stop(struct ifnet *ifp, int disable)
581{ 581{
582 struct usbnet * const un = ifp->if_softc; 582 struct usbnet * const un = ifp->if_softc;
583 struct smsc_softc * const sc = usbnet_softc(un); 583 struct smsc_softc * const sc = usbnet_softc(un);
584 584
@@ -747,34 +747,26 @@ smsc_uno_ioctl(struct ifnet *ifp, u_long @@ -747,34 +747,26 @@ smsc_uno_ioctl(struct ifnet *ifp, u_long
747 switch (cmd) { 747 switch (cmd) {
748 case SIOCSIFCAP: 748 case SIOCSIFCAP:
749 smsc_setoe_locked(un); 749 smsc_setoe_locked(un);
750 break; 750 break;
751 default: 751 default:
752 break; 752 break;
753 } 753 }
754 754
755 usbnet_unlock_core(un); 755 usbnet_unlock_core(un);
756 756
757 return 0; 757 return 0;
758} 758}
759 759
760static void 
761smsc_uno_mcast(struct ifnet *ifp) 
762{ 
763 struct usbnet * const un = ifp->if_softc; 
764 
765 smsc_setiff_locked(un); 
766} 
767 
768static int 760static int
769smsc_match(device_t parent, cfdata_t match, void *aux) 761smsc_match(device_t parent, cfdata_t match, void *aux)
770{ 762{
771 struct usb_attach_arg *uaa = aux; 763 struct usb_attach_arg *uaa = aux;
772 764
773 return (usb_lookup(smsc_devs, uaa->uaa_vendor, uaa->uaa_product) != NULL) ? 765 return (usb_lookup(smsc_devs, uaa->uaa_vendor, uaa->uaa_product) != NULL) ?
774 UMATCH_VENDOR_PRODUCT : UMATCH_NONE; 766 UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
775} 767}
776 768
777static void 769static void
778smsc_attach(device_t parent, device_t self, void *aux) 770smsc_attach(device_t parent, device_t self, void *aux)
779{ 771{
780 USBNET_MII_DECL_DEFAULT(unm); 772 USBNET_MII_DECL_DEFAULT(unm);

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

--- src/sys/dev/usb/if_udav.c 2022/03/03 05:52:46 1.85
+++ src/sys/dev/usb/if_udav.c 2022/03/03 05:53:04 1.86
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_udav.c,v 1.85 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_udav.c,v 1.86 2022/03/03 05:53:04 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.85 2022/03/03 05:52:46 riastradh Exp $"); 48__KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.86 2022/03/03 05:53:04 riastradh Exp $");
49 49
50#ifdef _KERNEL_OPT 50#ifdef _KERNEL_OPT
51#include "opt_usb.h" 51#include "opt_usb.h"
52#endif 52#endif
53 53
54#include <sys/param.h> 54#include <sys/param.h>
55 55
56#include <dev/usb/usbnet.h> 56#include <dev/usb/usbnet.h>
57#include <dev/usb/if_udavreg.h> 57#include <dev/usb/if_udavreg.h>
58 58
59/* Function declarations */ 59/* Function declarations */
60static int udav_match(device_t, cfdata_t, void *); 60static int udav_match(device_t, cfdata_t, void *);
61static void udav_attach(device_t, device_t, void *); 61static void udav_attach(device_t, device_t, void *);
@@ -64,27 +64,26 @@ CFATTACH_DECL_NEW(udav, sizeof(struct us @@ -64,27 +64,26 @@ CFATTACH_DECL_NEW(udav, sizeof(struct us
64 usbnet_detach, usbnet_activate); 64 usbnet_detach, usbnet_activate);
65 65
66static void udav_chip_init(struct usbnet *); 66static void udav_chip_init(struct usbnet *);
67 67
68static unsigned udav_uno_tx_prepare(struct usbnet *, struct mbuf *, 68static unsigned udav_uno_tx_prepare(struct usbnet *, struct mbuf *,
69 struct usbnet_chain *); 69 struct usbnet_chain *);
70static void udav_uno_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t); 70static void udav_uno_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
71static void udav_uno_stop(struct ifnet *, int); 71static void udav_uno_stop(struct ifnet *, int);
72static void udav_uno_mcast(struct ifnet *); 72static void udav_uno_mcast(struct ifnet *);
73static int udav_uno_mii_read_reg(struct usbnet *, int, int, uint16_t *); 73static int udav_uno_mii_read_reg(struct usbnet *, int, int, uint16_t *);
74static int udav_uno_mii_write_reg(struct usbnet *, int, int, uint16_t); 74static int udav_uno_mii_write_reg(struct usbnet *, int, int, uint16_t);
75static void udav_uno_mii_statchg(struct ifnet *); 75static void udav_uno_mii_statchg(struct ifnet *);
76static int udav_uno_init(struct ifnet *); 76static int udav_uno_init(struct ifnet *);
77static void udav_setiff_locked(struct usbnet *); 
78static void udav_reset(struct usbnet *); 77static void udav_reset(struct usbnet *);
79 78
80static int udav_csr_read(struct usbnet *, int, void *, int); 79static int udav_csr_read(struct usbnet *, int, void *, int);
81static int udav_csr_write(struct usbnet *, int, void *, int); 80static int udav_csr_write(struct usbnet *, int, void *, int);
82static int udav_csr_read1(struct usbnet *, int); 81static int udav_csr_read1(struct usbnet *, int);
83static int udav_csr_write1(struct usbnet *, int, unsigned char); 82static int udav_csr_write1(struct usbnet *, int, unsigned char);
84 83
85#if 0 84#if 0
86static int udav_mem_read(struct usbnet *, int, void *, int); 85static int udav_mem_read(struct usbnet *, int, void *, int);
87static int udav_mem_write(struct usbnet *, int, void *, int); 86static int udav_mem_write(struct usbnet *, int, void *, int);
88static int udav_mem_write1(struct usbnet *, int, unsigned char); 87static int udav_mem_write1(struct usbnet *, int, unsigned char);
89#endif 88#endif
90 89
@@ -491,27 +490,27 @@ udav_uno_init(struct ifnet *ifp) @@ -491,27 +490,27 @@ udav_uno_init(struct ifnet *ifp)
491 /* Disable loopback */ 490 /* Disable loopback */
492 UDAV_CLRBIT(un, UDAV_NCR, UDAV_NCR_LBK0 | UDAV_NCR_LBK1); 491 UDAV_CLRBIT(un, UDAV_NCR, UDAV_NCR_LBK0 | UDAV_NCR_LBK1);
493 492
494 /* Initialize RX control register */ 493 /* Initialize RX control register */
495 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_DIS_LONG | UDAV_RCR_DIS_CRC); 494 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_DIS_LONG | UDAV_RCR_DIS_CRC);
496 495
497 /* If we want promiscuous mode, accept all physical frames. */ 496 /* If we want promiscuous mode, accept all physical frames. */
498 if (ifp->if_flags & IFF_PROMISC) 497 if (ifp->if_flags & IFF_PROMISC)
499 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC); 498 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC);
500 else 499 else
501 UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC); 500 UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC);
502 501
503 /* Load the multicast filter */ 502 /* Load the multicast filter */
504 udav_setiff_locked(un); 503 udav_uno_mcast(ifp);
505 504
506 /* Enable RX */ 505 /* Enable RX */
507 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_RXEN); 506 UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_RXEN);
508 507
509 /* clear POWER_DOWN state of internal PHY */ 508 /* clear POWER_DOWN state of internal PHY */
510 UDAV_SETBIT(un, UDAV_GPCR, UDAV_GPCR_GEP_CNTL0); 509 UDAV_SETBIT(un, UDAV_GPCR, UDAV_GPCR_GEP_CNTL0);
511 UDAV_CLRBIT(un, UDAV_GPR, UDAV_GPR_GEPIO0); 510 UDAV_CLRBIT(un, UDAV_GPR, UDAV_GPR_GEPIO0);
512 511
513 if (mii && (rc = mii_mediachg(mii)) == ENXIO) 512 if (mii && (rc = mii_mediachg(mii)) == ENXIO)
514 rc = 0; 513 rc = 0;
515 514
516 if (rc != 0) { 515 if (rc != 0) {
517 return rc; 516 return rc;
@@ -566,30 +565,30 @@ udav_chip_init(struct usbnet *un) @@ -566,30 +565,30 @@ udav_chip_init(struct usbnet *un)
566 if (!(udav_csr_read1(un, UDAV_NCR) & UDAV_NCR_RST)) 565 if (!(udav_csr_read1(un, UDAV_NCR) & UDAV_NCR_RST))
567 break; 566 break;
568 delay(10); /* XXX */ 567 delay(10); /* XXX */
569 } 568 }
570 delay(10000); /* XXX */ 569 delay(10000); /* XXX */
571} 570}
572 571
573#define UDAV_BITS 6 572#define UDAV_BITS 6
574 573
575#define UDAV_CALCHASH(addr) \ 574#define UDAV_CALCHASH(addr) \
576 (ether_crc32_le((addr), ETHER_ADDR_LEN) & ((1 << UDAV_BITS) - 1)) 575 (ether_crc32_le((addr), ETHER_ADDR_LEN) & ((1 << UDAV_BITS) - 1))
577 576
578static void 577static void
579udav_setiff_locked(struct usbnet *un) 578udav_uno_mcast(struct ifnet *ifp)
580{ 579{
 580 struct usbnet * const un = ifp->if_softc;
581 struct ethercom *ec = usbnet_ec(un); 581 struct ethercom *ec = usbnet_ec(un);
582 struct ifnet * const ifp = usbnet_ifp(un); 
583 struct ether_multi *enm; 582 struct ether_multi *enm;
584 struct ether_multistep step; 583 struct ether_multistep step;
585 uint8_t hashes[8]; 584 uint8_t hashes[8];
586 int h = 0; 585 int h = 0;
587 586
588 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 587 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
589 588
590 usbnet_isowned_core(un); 589 usbnet_isowned_core(un);
591 590
592 if (usbnet_isdying(un)) 591 if (usbnet_isdying(un))
593 return; 592 return;
594 593
595 if (ISSET(un->un_flags, UDAV_NO_PHY)) { 594 if (ISSET(un->un_flags, UDAV_NO_PHY)) {
@@ -701,34 +700,26 @@ udav_uno_rx_loop(struct usbnet *un, stru @@ -701,34 +700,26 @@ udav_uno_rx_loop(struct usbnet *un, stru
701 pkt_len > total_len || 700 pkt_len > total_len ||
702 (pktstat & UDAV_RSR_ERR)) { 701 (pktstat & UDAV_RSR_ERR)) {
703 if_statinc(ifp, if_ierrors); 702 if_statinc(ifp, if_ierrors);
704 return; 703 return;
705 } 704 }
706 705
707 pkt_len -= ETHER_CRC_LEN; 706 pkt_len -= ETHER_CRC_LEN;
708 707
709 DPRINTF(("%s: Rx deliver: 0x%02x\n", device_xname(un->un_dev), pkt_len)); 708 DPRINTF(("%s: Rx deliver: 0x%02x\n", device_xname(un->un_dev), pkt_len));
710 709
711 usbnet_enqueue(un, buf, pkt_len, 0, 0, 0); 710 usbnet_enqueue(un, buf, pkt_len, 0, 0, 0);
712} 711}
713 712
714static void 
715udav_uno_mcast(struct ifnet *ifp) 
716{ 
717 struct usbnet * const un = ifp->if_softc; 
718 
719 udav_setiff_locked(un); 
720} 
721 
722/* Stop the adapter and free any mbufs allocated to the RX and TX lists. */ 713/* Stop the adapter and free any mbufs allocated to the RX and TX lists. */
723static void 714static void
724udav_uno_stop(struct ifnet *ifp, int disable) 715udav_uno_stop(struct ifnet *ifp, int disable)
725{ 716{
726 struct usbnet * const un = ifp->if_softc; 717 struct usbnet * const un = ifp->if_softc;
727 718
728 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 719 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
729 720
730 udav_reset(un); 721 udav_reset(un);
731} 722}
732 723
733static int 724static int
734udav_uno_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val) 725udav_uno_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)

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

--- src/sys/dev/usb/if_ure.c 2022/03/03 05:52:46 1.47
+++ src/sys/dev/usb/if_ure.c 2022/03/03 05:53:04 1.48
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_ure.c,v 1.47 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_ure.c,v 1.48 2022/03/03 05:53:04 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.47 2022/03/03 05:52:46 riastradh Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: if_ure.c,v 1.48 2022/03/03 05:53:04 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
@@ -321,30 +321,30 @@ ure_uno_miibus_statchg(struct ifnet *ifp @@ -321,30 +321,30 @@ ure_uno_miibus_statchg(struct ifnet *ifp
321 break; 321 break;
322 case IFM_1000_T: 322 case IFM_1000_T:
323 if ((un->un_flags & URE_FLAG_8152) != 0) 323 if ((un->un_flags & URE_FLAG_8152) != 0)
324 break; 324 break;
325 usbnet_set_link(un, true); 325 usbnet_set_link(un, true);
326 break; 326 break;
327 default: 327 default:
328 break; 328 break;
329 } 329 }
330 } 330 }
331} 331}
332 332
333static void 333static void
334ure_rcvfilt_locked(struct usbnet *un) 334ure_uno_mcast(struct ifnet *ifp)
335{ 335{
 336 struct usbnet *un = ifp->if_softc;
336 struct ethercom *ec = usbnet_ec(un); 337 struct ethercom *ec = usbnet_ec(un);
337 struct ifnet *ifp = usbnet_ifp(un); 
338 struct ether_multi *enm; 338 struct ether_multi *enm;
339 struct ether_multistep step; 339 struct ether_multistep step;
340 uint32_t mchash[2] = { 0, 0 }; 340 uint32_t mchash[2] = { 0, 0 };
341 uint32_t h = 0, rxmode; 341 uint32_t h = 0, rxmode;
342 342
343 usbnet_isowned_core(un); 343 usbnet_isowned_core(un);
344 344
345 if (usbnet_isdying(un)) 345 if (usbnet_isdying(un))
346 return; 346 return;
347 347
348 rxmode = ure_read_4(un, URE_PLA_RCR, URE_MCU_TYPE_PLA); 348 rxmode = ure_read_4(un, URE_PLA_RCR, URE_MCU_TYPE_PLA);
349 rxmode &= ~(URE_RCR_AAP | URE_RCR_AM); 349 rxmode &= ~(URE_RCR_AAP | URE_RCR_AM);
350 /* continue to accept my own DA and bcast frames */ 350 /* continue to accept my own DA and bcast frames */
@@ -438,27 +438,27 @@ ure_uno_init(struct ifnet *ifp) @@ -438,27 +438,27 @@ ure_uno_init(struct ifnet *ifp)
438 ure_read_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA) | 438 ure_read_2(un, URE_PLA_FMC, URE_MCU_TYPE_PLA) |
439 URE_FMC_FCR_MCU_EN); 439 URE_FMC_FCR_MCU_EN);
440 440
441 /* Enable transmit and receive. */ 441 /* Enable transmit and receive. */
442 ure_write_1(un, URE_PLA_CR, URE_MCU_TYPE_PLA, 442 ure_write_1(un, URE_PLA_CR, URE_MCU_TYPE_PLA,
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_uno_mcast(ifp);
452 452
453 return usbnet_init_rx_tx(un); 453 return usbnet_init_rx_tx(un);
454} 454}
455 455
456static void 456static void
457ure_uno_stop(struct ifnet *ifp, int disable __unused) 457ure_uno_stop(struct ifnet *ifp, int disable __unused)
458{ 458{
459 struct usbnet * const un = ifp->if_softc; 459 struct usbnet * const un = ifp->if_softc;
460 460
461 ure_reset(un); 461 ure_reset(un);
462} 462}
463 463
464static void 464static void
@@ -780,34 +780,26 @@ ure_init_fifo(struct usbnet *un) @@ -780,34 +780,26 @@ ure_init_fifo(struct usbnet *un)
780 rx_fifo2 = URE_RXFIFO_THR3_FULL; 780 rx_fifo2 = URE_RXFIFO_THR3_FULL;
781 } else { 781 } else {
782 rx_fifo1 = URE_RXFIFO_THR2_HIGH; 782 rx_fifo1 = URE_RXFIFO_THR2_HIGH;
783 rx_fifo2 = URE_RXFIFO_THR3_HIGH; 783 rx_fifo2 = URE_RXFIFO_THR3_HIGH;
784 } 784 }
785 ure_write_4(un, URE_PLA_RXFIFO_CTRL1, URE_MCU_TYPE_PLA, rx_fifo1); 785 ure_write_4(un, URE_PLA_RXFIFO_CTRL1, URE_MCU_TYPE_PLA, rx_fifo1);
786 ure_write_4(un, URE_PLA_RXFIFO_CTRL2, URE_MCU_TYPE_PLA, rx_fifo2); 786 ure_write_4(un, URE_PLA_RXFIFO_CTRL2, URE_MCU_TYPE_PLA, rx_fifo2);
787 787
788 /* Configure Tx FIFO threshold. */ 788 /* Configure Tx FIFO threshold. */
789 ure_write_4(un, URE_PLA_TXFIFO_CTRL, URE_MCU_TYPE_PLA, 789 ure_write_4(un, URE_PLA_TXFIFO_CTRL, URE_MCU_TYPE_PLA,
790 URE_TXFIFO_THR_NORMAL); 790 URE_TXFIFO_THR_NORMAL);
791} 791}
792 792
793static void 
794ure_uno_mcast(struct ifnet *ifp) 
795{ 
796 struct usbnet * const un = ifp->if_softc; 
797 
798 ure_rcvfilt_locked(un); 
799} 
800 
801static int 793static int
802ure_match(device_t parent, cfdata_t match, void *aux) 794ure_match(device_t parent, cfdata_t match, void *aux)
803{ 795{
804 struct usb_attach_arg *uaa = aux; 796 struct usb_attach_arg *uaa = aux;
805 797
806 return usb_lookup(ure_devs, uaa->uaa_vendor, uaa->uaa_product) != NULL ? 798 return usb_lookup(ure_devs, uaa->uaa_vendor, uaa->uaa_product) != NULL ?
807 UMATCH_VENDOR_PRODUCT : UMATCH_NONE; 799 UMATCH_VENDOR_PRODUCT : UMATCH_NONE;
808} 800}
809 801
810static void 802static void
811ure_attach(device_t parent, device_t self, void *aux) 803ure_attach(device_t parent, device_t self, void *aux)
812{ 804{
813 USBNET_MII_DECL_DEFAULT(unm); 805 USBNET_MII_DECL_DEFAULT(unm);

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

--- src/sys/dev/usb/if_url.c 2022/03/03 05:52:46 1.86
+++ src/sys/dev/usb/if_url.c 2022/03/03 05:53:04 1.87
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_url.c,v 1.86 2022/03/03 05:52:46 riastradh Exp $ */ 1/* $NetBSD: if_url.c,v 1.87 2022/03/03 05:53:04 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.86 2022/03/03 05:52:46 riastradh Exp $"); 47__KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1.87 2022/03/03 05:53:04 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
@@ -67,31 +67,30 @@ __KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1 @@ -67,31 +67,30 @@ __KERNEL_RCSID(0, "$NetBSD: if_url.c,v 1
67 67
68/* Function declarations */ 68/* Function declarations */
69static int url_match(device_t, cfdata_t, void *); 69static int url_match(device_t, cfdata_t, void *);
70static void url_attach(device_t, device_t, void *); 70static void url_attach(device_t, device_t, void *);
71 71
72CFATTACH_DECL_NEW(url, sizeof(struct usbnet), url_match, url_attach, 72CFATTACH_DECL_NEW(url, sizeof(struct usbnet), url_match, url_attach,
73 usbnet_detach, usbnet_activate); 73 usbnet_detach, usbnet_activate);
74 74
75static unsigned url_uno_tx_prepare(struct usbnet *, struct mbuf *, 75static unsigned url_uno_tx_prepare(struct usbnet *, struct mbuf *,
76 struct usbnet_chain *); 76 struct usbnet_chain *);
77static void url_uno_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t); 77static void url_uno_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
78static int url_uno_mii_read_reg(struct usbnet *, int, int, uint16_t *); 78static int url_uno_mii_read_reg(struct usbnet *, int, int, uint16_t *);
79static int url_uno_mii_write_reg(struct usbnet *, int, int, uint16_t); 79static int url_uno_mii_write_reg(struct usbnet *, int, int, uint16_t);
80static void url_uno_mcast(struct ifnet *); 
81static void url_uno_stop(struct ifnet *, int); 80static void url_uno_stop(struct ifnet *, int);
82static void url_uno_mii_statchg(struct ifnet *); 81static void url_uno_mii_statchg(struct ifnet *);
83static int url_uno_init(struct ifnet *); 82static int url_uno_init(struct ifnet *);
84static void url_rcvfilt_locked(struct usbnet *); 83static void url_uno_mcast(struct ifnet *);
85static void url_reset(struct usbnet *); 84static void url_reset(struct usbnet *);
86 85
87static int url_csr_read_1(struct usbnet *, int); 86static int url_csr_read_1(struct usbnet *, int);
88static int url_csr_read_2(struct usbnet *, int); 87static int url_csr_read_2(struct usbnet *, int);
89static int url_csr_write_1(struct usbnet *, int, int); 88static int url_csr_write_1(struct usbnet *, int, int);
90static int url_csr_write_2(struct usbnet *, int, int); 89static int url_csr_write_2(struct usbnet *, int, int);
91static int url_csr_write_4(struct usbnet *, int, int); 90static int url_csr_write_4(struct usbnet *, int, int);
92static int url_mem(struct usbnet *, int, int, void *, int); 91static int url_mem(struct usbnet *, int, int, void *, int);
93 92
94static const struct usbnet_ops url_ops = { 93static const struct usbnet_ops url_ops = {
95 .uno_stop = url_uno_stop, 94 .uno_stop = url_uno_stop,
96 .uno_mcast = url_uno_mcast, 95 .uno_mcast = url_uno_mcast,
97 .uno_read_reg = url_uno_mii_read_reg, 96 .uno_read_reg = url_uno_mii_read_reg,
@@ -383,27 +382,27 @@ url_uno_init(struct ifnet *ifp) @@ -383,27 +382,27 @@ url_uno_init(struct ifnet *ifp)
383 for (i = 0; i < ETHER_ADDR_LEN; i++) 382 for (i = 0; i < ETHER_ADDR_LEN; i++)
384 url_csr_write_1(un, URL_IDR0 + i, eaddr[i]); 383 url_csr_write_1(un, URL_IDR0 + i, eaddr[i]);
385 384
386 /* Init transmission control register */ 385 /* Init transmission control register */
387 URL_CLRBIT(un, URL_TCR, 386 URL_CLRBIT(un, URL_TCR,
388 URL_TCR_TXRR1 | URL_TCR_TXRR0 | 387 URL_TCR_TXRR1 | URL_TCR_TXRR0 |
389 URL_TCR_IFG1 | URL_TCR_IFG0 | 388 URL_TCR_IFG1 | URL_TCR_IFG0 |
390 URL_TCR_NOCRC); 389 URL_TCR_NOCRC);
391 390
392 /* Init receive control register */ 391 /* Init receive control register */
393 URL_SETBIT2(un, URL_RCR, URL_RCR_TAIL | URL_RCR_AD | URL_RCR_AB); 392 URL_SETBIT2(un, URL_RCR, URL_RCR_TAIL | URL_RCR_AD | URL_RCR_AB);
394 393
395 /* Accept multicast frame or run promisc. mode */ 394 /* Accept multicast frame or run promisc. mode */
396 url_rcvfilt_locked(un); 395 url_uno_mcast(ifp);
397 396
398 /* Enable RX and TX */ 397 /* Enable RX and TX */
399 URL_SETBIT(un, URL_CR, URL_CR_TE | URL_CR_RE); 398 URL_SETBIT(un, URL_CR, URL_CR_TE | URL_CR_RE);
400 399
401 return usbnet_init_rx_tx(un); 400 return usbnet_init_rx_tx(un);
402} 401}
403 402
404static void 403static void
405url_reset(struct usbnet *un) 404url_reset(struct usbnet *un)
406{ 405{
407 int i; 406 int i;
408 407
409 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 408 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
@@ -415,29 +414,29 @@ url_reset(struct usbnet *un) @@ -415,29 +414,29 @@ url_reset(struct usbnet *un)
415 414
416 for (i = 0; i < URL_TX_TIMEOUT; i++) { 415 for (i = 0; i < URL_TX_TIMEOUT; i++) {
417 if (usbnet_isdying(un)) 416 if (usbnet_isdying(un))
418 return; 417 return;
419 if (!(url_csr_read_1(un, URL_CR) & URL_CR_SOFT_RST)) 418 if (!(url_csr_read_1(un, URL_CR) & URL_CR_SOFT_RST))
420 break; 419 break;
421 delay(10); /* XXX */ 420 delay(10); /* XXX */
422 } 421 }
423 422
424 delay(10000); /* XXX */ 423 delay(10000); /* XXX */
425} 424}
426 425
427static void 426static void
428url_rcvfilt_locked(struct usbnet *un) 427url_uno_mcast(struct ifnet *ifp)
429{ 428{
430 struct ifnet * const ifp = usbnet_ifp(un); 429 struct usbnet * const un = ifp->if_softc;
431 struct ethercom *ec = usbnet_ec(un); 430 struct ethercom *ec = usbnet_ec(un);
432 struct ether_multi *enm; 431 struct ether_multi *enm;
433 struct ether_multistep step; 432 struct ether_multistep step;
434 uint32_t mchash[2] = { 0, 0 }; 433 uint32_t mchash[2] = { 0, 0 };
435 int h = 0, rcr; 434 int h = 0, rcr;
436 435
437 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 436 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
438 437
439 usbnet_isowned_core(un); 438 usbnet_isowned_core(un);
440 439
441 if (usbnet_isdying(un)) 440 if (usbnet_isdying(un))
442 return; 441 return;
443 442
@@ -535,34 +534,26 @@ url_uno_rx_loop(struct usbnet *un, struc @@ -535,34 +534,26 @@ url_uno_rx_loop(struct usbnet *un, struc
535 total_len -= ETHER_CRC_LEN; 534 total_len -= ETHER_CRC_LEN;
536 535
537 DPRINTF(("%s: %s: deliver %d\n", device_xname(un->un_dev), 536 DPRINTF(("%s: %s: deliver %d\n", device_xname(un->un_dev),
538 __func__, total_len)); 537 __func__, total_len));
539 usbnet_enqueue(un, c->unc_buf, total_len, 0, 0, 0); 538 usbnet_enqueue(un, c->unc_buf, total_len, 0, 0, 0);
540} 539}
541 540
542#if 0 541#if 0
543static void url_intr(void) 542static void url_intr(void)
544{ 543{
545} 544}
546#endif 545#endif
547 546
548static void 
549url_uno_mcast(struct ifnet *ifp) 
550{ 
551 struct usbnet * const un = ifp->if_softc; 
552 
553 url_rcvfilt_locked(un); 
554} 
555 
556/* Stop the adapter and free any mbufs allocated to the RX and TX lists. */ 547/* Stop the adapter and free any mbufs allocated to the RX and TX lists. */
557static void 548static void
558url_uno_stop(struct ifnet *ifp, int disable) 549url_uno_stop(struct ifnet *ifp, int disable)
559{ 550{
560 struct usbnet * const un = ifp->if_softc; 551 struct usbnet * const un = ifp->if_softc;
561 552
562 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__)); 553 DPRINTF(("%s: %s: enter\n", device_xname(un->un_dev), __func__));
563 554
564 url_reset(un); 555 url_reset(un);
565} 556}
566 557
567static int 558static int
568url_uno_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val) 559url_uno_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)