if_re.c (129879) | if_re.c (130270) |
---|---|
1/* 2 * Copyright (c) 1997, 1998-2003 3 * Bill Paul <wpaul@windriver.com>. 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-2003 3 * Bill Paul <wpaul@windriver.com>. 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/dev/re/if_re.c 129879 2004-05-30 20:08:47Z phk $"); | 34__FBSDID("$FreeBSD: head/sys/dev/re/if_re.c 130270 2004-06-09 14:34:04Z naddy $"); |
35 36/* 37 * RealTek 8139C+/8169/8169S/8110S PCI NIC driver 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Networking Software Engineer 41 * Wind River Systems 42 */ --- 178 unchanged lines hidden (view full) --- 221static void re_read_eeprom (struct rl_softc *, caddr_t, int, int, int); 222static int re_gmii_readreg (device_t, int, int); 223static int re_gmii_writereg (device_t, int, int, int); 224 225static int re_miibus_readreg (device_t, int, int); 226static int re_miibus_writereg (device_t, int, int, int); 227static void re_miibus_statchg (device_t); 228 | 35 36/* 37 * RealTek 8139C+/8169/8169S/8110S PCI NIC driver 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Networking Software Engineer 41 * Wind River Systems 42 */ --- 178 unchanged lines hidden (view full) --- 221static void re_read_eeprom (struct rl_softc *, caddr_t, int, int, int); 222static int re_gmii_readreg (device_t, int, int); 223static int re_gmii_writereg (device_t, int, int, int); 224 225static int re_miibus_readreg (device_t, int, int); 226static int re_miibus_writereg (device_t, int, int, int); 227static void re_miibus_statchg (device_t); 228 |
229static uint32_t re_mchash (const uint8_t *); | |
230static void re_setmulti (struct rl_softc *); 231static void re_reset (struct rl_softc *); 232 233static int re_diag (struct rl_softc *); 234 235#ifdef RE_USEIOSPACE 236#define RL_RES SYS_RES_IOPORT 237#define RL_RID RL_PCI_LOIO --- 331 unchanged lines hidden (view full) --- 569static void 570re_miibus_statchg(dev) 571 device_t dev; 572{ 573 return; 574} 575 576/* | 229static void re_setmulti (struct rl_softc *); 230static void re_reset (struct rl_softc *); 231 232static int re_diag (struct rl_softc *); 233 234#ifdef RE_USEIOSPACE 235#define RL_RES SYS_RES_IOPORT 236#define RL_RID RL_PCI_LOIO --- 331 unchanged lines hidden (view full) --- 568static void 569re_miibus_statchg(dev) 570 device_t dev; 571{ 572 return; 573} 574 575/* |
577 * Calculate CRC of a multicast group address, return the upper 6 bits. 578 */ 579static uint32_t 580re_mchash(addr) 581 const uint8_t *addr; 582{ 583 uint32_t crc, carry; 584 int idx, bit; 585 uint8_t data; 586 587 /* Compute CRC for the address value. */ 588 crc = 0xFFFFFFFF; /* initial value */ 589 590 for (idx = 0; idx < 6; idx++) { 591 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 592 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); 593 crc <<= 1; 594 if (carry) 595 crc = (crc ^ 0x04c11db6) | carry; 596 } 597 } 598 599 /* return the filter bit position */ 600 return(crc >> 26); 601} 602 603/* | |
604 * Program the 64-bit multicast hash filter. 605 */ 606static void 607re_setmulti(sc) 608 struct rl_softc *sc; 609{ 610 struct ifnet *ifp; 611 int h = 0; --- 17 unchanged lines hidden (view full) --- 629 /* first, zot all the existing hash bits */ 630 CSR_WRITE_4(sc, RL_MAR0, 0); 631 CSR_WRITE_4(sc, RL_MAR4, 0); 632 633 /* now program new ones */ 634 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 635 if (ifma->ifma_addr->sa_family != AF_LINK) 636 continue; | 576 * Program the 64-bit multicast hash filter. 577 */ 578static void 579re_setmulti(sc) 580 struct rl_softc *sc; 581{ 582 struct ifnet *ifp; 583 int h = 0; --- 17 unchanged lines hidden (view full) --- 601 /* first, zot all the existing hash bits */ 602 CSR_WRITE_4(sc, RL_MAR0, 0); 603 CSR_WRITE_4(sc, RL_MAR4, 0); 604 605 /* now program new ones */ 606 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 607 if (ifma->ifma_addr->sa_family != AF_LINK) 608 continue; |
637 h = re_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 609 h = ether_crc32_be(LLADDR((struct sockaddr_dl *) 610 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; |
638 if (h < 32) 639 hashes[0] |= (1 << h); 640 else 641 hashes[1] |= (1 << (h - 32)); 642 mcnt++; 643 } 644 645 if (mcnt) --- 1858 unchanged lines hidden --- | 611 if (h < 32) 612 hashes[0] |= (1 << h); 613 else 614 hashes[1] |= (1 << (h - 32)); 615 mcnt++; 616 } 617 618 if (mcnt) --- 1858 unchanged lines hidden --- |