| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_udav.c,v 1.98 2022/08/20 14:08:59 riastradh Exp $ */ | | 1 | /* $NetBSD: if_udav.c,v 1.99 2022/08/20 14:09:20 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.98 2022/08/20 14:08:59 riastradh Exp $"); | | 48 | __KERNEL_RCSID(0, "$NetBSD: if_udav.c,v 1.99 2022/08/20 14:09:20 riastradh Exp $"); |
49 | | | 49 | |
50 | #ifdef _KERNEL_OPT | | 50 | #ifdef _KERNEL_OPT |
51 | #include "opt_usb.h" | | 51 | #include "opt_usb.h" |
52 | #endif | | 52 | #endif |
53 | | | 53 | |
54 | #include <sys/param.h> | | 54 | #include <sys/param.h> |
55 | | | 55 | |
56 | #include <dev/usb/usbnet.h> | | 56 | #include <dev/usb/usbnet.h> |
57 | #include <dev/usb/if_udavreg.h> | | 57 | #include <dev/usb/if_udavreg.h> |
58 | | | 58 | |
59 | /* Function declarations */ | | 59 | /* Function declarations */ |
60 | static int udav_match(device_t, cfdata_t, void *); | | 60 | static int udav_match(device_t, cfdata_t, void *); |
61 | static void udav_attach(device_t, device_t, void *); | | 61 | static void udav_attach(device_t, device_t, void *); |
| @@ -572,48 +572,44 @@ udav_uno_mcast(struct ifnet *ifp) | | | @@ -572,48 +572,44 @@ udav_uno_mcast(struct ifnet *ifp) |
572 | | | 572 | |
573 | if (ISSET(un->un_flags, UDAV_NO_PHY)) { | | 573 | if (ISSET(un->un_flags, UDAV_NO_PHY)) { |
574 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL); | | 574 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL); |
575 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_PRMSC); | | 575 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_PRMSC); |
576 | return; | | 576 | return; |
577 | } | | 577 | } |
578 | | | 578 | |
579 | if (usbnet_ispromisc(un)) { | | 579 | if (usbnet_ispromisc(un)) { |
580 | ETHER_LOCK(ec); | | 580 | ETHER_LOCK(ec); |
581 | ec->ec_flags |= ETHER_F_ALLMULTI; | | 581 | ec->ec_flags |= ETHER_F_ALLMULTI; |
582 | ETHER_UNLOCK(ec); | | 582 | ETHER_UNLOCK(ec); |
583 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC); | | 583 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL | UDAV_RCR_PRMSC); |
584 | return; | | 584 | return; |
585 | } else if (ifp->if_flags & IFF_ALLMULTI) { /* XXX ??? Can't happen? */ | | | |
586 | ETHER_LOCK(ec); | | | |
587 | allmulti: | | | |
588 | ec->ec_flags |= ETHER_F_ALLMULTI; | | | |
589 | ETHER_UNLOCK(ec); | | | |
590 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL); | | | |
591 | UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_PRMSC); | | | |
592 | return; | | | |
593 | } | | 585 | } |
594 | | | 586 | |
595 | /* first, zot all the existing hash bits */ | | 587 | /* first, zot all the existing hash bits */ |
596 | memset(hashes, 0x00, sizeof(hashes)); | | 588 | memset(hashes, 0x00, sizeof(hashes)); |
597 | hashes[7] |= 0x80; /* broadcast address */ | | 589 | hashes[7] |= 0x80; /* broadcast address */ |
598 | udav_csr_write(un, UDAV_MAR, hashes, sizeof(hashes)); | | 590 | udav_csr_write(un, UDAV_MAR, hashes, sizeof(hashes)); |
599 | | | 591 | |
600 | /* now program new ones */ | | 592 | /* now program new ones */ |
601 | ETHER_LOCK(ec); | | 593 | ETHER_LOCK(ec); |
602 | ETHER_FIRST_MULTI(step, ec, enm); | | 594 | ETHER_FIRST_MULTI(step, ec, enm); |
603 | while (enm != NULL) { | | 595 | while (enm != NULL) { |
604 | if (memcmp(enm->enm_addrlo, enm->enm_addrhi, | | 596 | if (memcmp(enm->enm_addrlo, enm->enm_addrhi, |
605 | ETHER_ADDR_LEN) != 0) { | | 597 | ETHER_ADDR_LEN) != 0) { |
606 | goto allmulti; | | 598 | ec->ec_flags |= ETHER_F_ALLMULTI; |
| | | 599 | ETHER_UNLOCK(ec); |
| | | 600 | UDAV_SETBIT(un, UDAV_RCR, UDAV_RCR_ALL); |
| | | 601 | UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_PRMSC); |
| | | 602 | return; |
607 | } | | 603 | } |
608 | | | 604 | |
609 | h = UDAV_CALCHASH(enm->enm_addrlo); | | 605 | h = UDAV_CALCHASH(enm->enm_addrlo); |
610 | hashes[h>>3] |= 1 << (h & 0x7); | | 606 | hashes[h>>3] |= 1 << (h & 0x7); |
611 | ETHER_NEXT_MULTI(step, enm); | | 607 | ETHER_NEXT_MULTI(step, enm); |
612 | } | | 608 | } |
613 | ec->ec_flags &= ~ETHER_F_ALLMULTI; | | 609 | ec->ec_flags &= ~ETHER_F_ALLMULTI; |
614 | ETHER_UNLOCK(ec); | | 610 | ETHER_UNLOCK(ec); |
615 | | | 611 | |
616 | /* disable all multicast */ | | 612 | /* disable all multicast */ |
617 | UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_ALL); | | 613 | UDAV_CLRBIT(un, UDAV_RCR, UDAV_RCR_ALL); |
618 | | | 614 | |
619 | /* write hash value to the register */ | | 615 | /* write hash value to the register */ |