if_wb.c (129878) | if_wb.c (130270) |
---|---|
1/* 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1997, 1998 3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33#include <sys/cdefs.h> |
34__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 129878 2004-05-30 20:00:41Z phk $"); | 34__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 130270 2004-06-09 14:34:04Z naddy $"); |
35 36/* 37 * Winbond fast ethernet PCI NIC driver 38 * 39 * Supports various cheap network adapters based on the Winbond W89C840F 40 * fast ethernet controller chip. This includes adapters manufactured by 41 * Winbond itself and some made by Linksys. 42 * --- 127 unchanged lines hidden (view full) --- 170static void wb_eeprom_getword (struct wb_softc *, int, u_int16_t *); 171static void wb_read_eeprom (struct wb_softc *, caddr_t, int, int, int); 172static void wb_mii_sync (struct wb_softc *); 173static void wb_mii_send (struct wb_softc *, u_int32_t, int); 174static int wb_mii_readreg (struct wb_softc *, struct wb_mii_frame *); 175static int wb_mii_writereg (struct wb_softc *, struct wb_mii_frame *); 176 177static void wb_setcfg (struct wb_softc *, u_int32_t); | 35 36/* 37 * Winbond fast ethernet PCI NIC driver 38 * 39 * Supports various cheap network adapters based on the Winbond W89C840F 40 * fast ethernet controller chip. This includes adapters manufactured by 41 * Winbond itself and some made by Linksys. 42 * --- 127 unchanged lines hidden (view full) --- 170static void wb_eeprom_getword (struct wb_softc *, int, u_int16_t *); 171static void wb_read_eeprom (struct wb_softc *, caddr_t, int, int, int); 172static void wb_mii_sync (struct wb_softc *); 173static void wb_mii_send (struct wb_softc *, u_int32_t, int); 174static int wb_mii_readreg (struct wb_softc *, struct wb_mii_frame *); 175static int wb_mii_writereg (struct wb_softc *, struct wb_mii_frame *); 176 177static void wb_setcfg (struct wb_softc *, u_int32_t); |
178static uint32_t wb_mchash (const uint8_t *); | |
179static void wb_setmulti (struct wb_softc *); 180static void wb_reset (struct wb_softc *); 181static void wb_fixmedia (struct wb_softc *); 182static int wb_list_rx_init (struct wb_softc *); 183static int wb_list_tx_init (struct wb_softc *); 184 185static int wb_miibus_readreg (device_t, int, int); 186static int wb_miibus_writereg (device_t, int, int, int); --- 395 unchanged lines hidden (view full) --- 582 WB_LOCK(sc); 583 mii = device_get_softc(sc->wb_miibus); 584 wb_setcfg(sc, mii->mii_media_active); 585 WB_UNLOCK(sc); 586 587 return; 588} 589 | 178static void wb_setmulti (struct wb_softc *); 179static void wb_reset (struct wb_softc *); 180static void wb_fixmedia (struct wb_softc *); 181static int wb_list_rx_init (struct wb_softc *); 182static int wb_list_tx_init (struct wb_softc *); 183 184static int wb_miibus_readreg (device_t, int, int); 185static int wb_miibus_writereg (device_t, int, int, int); --- 395 unchanged lines hidden (view full) --- 581 WB_LOCK(sc); 582 mii = device_get_softc(sc->wb_miibus); 583 wb_setcfg(sc, mii->mii_media_active); 584 WB_UNLOCK(sc); 585 586 return; 587} 588 |
590static u_int32_t 591wb_mchash(addr) 592 const uint8_t *addr; 593{ 594 uint32_t crc, carry; 595 int idx, bit; 596 uint8_t data; 597 598 /* Compute CRC for the address value. */ 599 crc = 0xFFFFFFFF; /* initial value */ 600 601 for (idx = 0; idx < 6; idx++) { 602 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 603 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); 604 crc <<= 1; 605 if (carry) 606 crc = (crc ^ 0x04c11db6) | carry; 607 } 608 } 609 610 /* 611 * return the filter bit position 612 * Note: I arrived at the following nonsense 613 * through experimentation. It's not the usual way to 614 * generate the bit position but it's the only thing 615 * I could come up with that works. 616 */ 617 return(~(crc >> 26) & 0x0000003F); 618} 619 | |
620/* 621 * Program the 64-bit multicast hash filter. 622 */ 623static void 624wb_setmulti(sc) 625 struct wb_softc *sc; 626{ 627 struct ifnet *ifp; --- 18 unchanged lines hidden (view full) --- 646 /* first, zot all the existing hash bits */ 647 CSR_WRITE_4(sc, WB_MAR0, 0); 648 CSR_WRITE_4(sc, WB_MAR1, 0); 649 650 /* now program new ones */ 651 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 652 if (ifma->ifma_addr->sa_family != AF_LINK) 653 continue; | 589/* 590 * Program the 64-bit multicast hash filter. 591 */ 592static void 593wb_setmulti(sc) 594 struct wb_softc *sc; 595{ 596 struct ifnet *ifp; --- 18 unchanged lines hidden (view full) --- 615 /* first, zot all the existing hash bits */ 616 CSR_WRITE_4(sc, WB_MAR0, 0); 617 CSR_WRITE_4(sc, WB_MAR1, 0); 618 619 /* now program new ones */ 620 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 621 if (ifma->ifma_addr->sa_family != AF_LINK) 622 continue; |
654 h = wb_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 623 h = ~ether_crc32_be(LLADDR((struct sockaddr_dl *) 624 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; |
655 if (h < 32) 656 hashes[0] |= (1 << h); 657 else 658 hashes[1] |= (1 << (h - 32)); 659 mcnt++; 660 } 661 662 if (mcnt) --- 1224 unchanged lines hidden --- | 625 if (h < 32) 626 hashes[0] |= (1 << h); 627 else 628 hashes[1] |= (1 << (h - 32)); 629 mcnt++; 630 } 631 632 if (mcnt) --- 1224 unchanged lines hidden --- |