if_vr.c (129878) | if_vr.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/dev/vr/if_vr.c 129878 2004-05-30 20:00:41Z phk $"); | 34__FBSDID("$FreeBSD: head/sys/dev/vr/if_vr.c 130270 2004-06-09 14:34:04Z naddy $"); |
35 36/* 37 * VIA Rhine fast ethernet PCI NIC driver 38 * 39 * Supports various network adapters based on the VIA Rhine 40 * and Rhine II PCI controllers, including the D-Link DFE530TX. 41 * Datasheets are available at http://www.via.com.tw. 42 * --- 112 unchanged lines hidden (view full) --- 155#endif 156static int vr_mii_readreg (struct vr_softc *, struct vr_mii_frame *); 157static int vr_mii_writereg (struct vr_softc *, struct vr_mii_frame *); 158static int vr_miibus_readreg (device_t, int, int); 159static int vr_miibus_writereg (device_t, int, int, int); 160static void vr_miibus_statchg (device_t); 161 162static void vr_setcfg (struct vr_softc *, int); | 35 36/* 37 * VIA Rhine fast ethernet PCI NIC driver 38 * 39 * Supports various network adapters based on the VIA Rhine 40 * and Rhine II PCI controllers, including the D-Link DFE530TX. 41 * Datasheets are available at http://www.via.com.tw. 42 * --- 112 unchanged lines hidden (view full) --- 155#endif 156static int vr_mii_readreg (struct vr_softc *, struct vr_mii_frame *); 157static int vr_mii_writereg (struct vr_softc *, struct vr_mii_frame *); 158static int vr_miibus_readreg (device_t, int, int); 159static int vr_miibus_writereg (device_t, int, int, int); 160static void vr_miibus_statchg (device_t); 161 162static void vr_setcfg (struct vr_softc *, int); |
163static uint32_t vr_mchash (const uint8_t *); | |
164static void vr_setmulti (struct vr_softc *); 165static void vr_reset (struct vr_softc *); 166static int vr_list_rx_init (struct vr_softc *); 167static int vr_list_tx_init (struct vr_softc *); 168 169#ifdef VR_USEIOSPACE 170#define VR_RES SYS_RES_IOPORT 171#define VR_RID VR_PCI_LOIO --- 385 unchanged lines hidden (view full) --- 557 mii = device_get_softc(sc->vr_miibus); 558 vr_setcfg(sc, mii->mii_media_active); 559 VR_UNLOCK(sc); 560 561 return; 562} 563 564/* | 163static void vr_setmulti (struct vr_softc *); 164static void vr_reset (struct vr_softc *); 165static int vr_list_rx_init (struct vr_softc *); 166static int vr_list_tx_init (struct vr_softc *); 167 168#ifdef VR_USEIOSPACE 169#define VR_RES SYS_RES_IOPORT 170#define VR_RID VR_PCI_LOIO --- 385 unchanged lines hidden (view full) --- 556 mii = device_get_softc(sc->vr_miibus); 557 vr_setcfg(sc, mii->mii_media_active); 558 VR_UNLOCK(sc); 559 560 return; 561} 562 563/* |
565 * Calculate CRC of a multicast group address, return the lower 6 bits. 566 */ 567static u_int32_t 568vr_mchash(addr) 569 const uint8_t *addr; 570{ 571 uint32_t crc, carry; 572 int idx, bit; 573 uint8_t data; 574 575 /* Compute CRC for the address value. */ 576 crc = 0xFFFFFFFF; /* initial value */ 577 578 for (idx = 0; idx < 6; idx++) { 579 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 580 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); 581 crc <<= 1; 582 if (carry) 583 crc = (crc ^ 0x04c11db6) | carry; 584 } 585 } 586 587 /* return the filter bit position */ 588 return((crc >> 26) & 0x0000003F); 589} 590 591/* | |
592 * Program the 64-bit multicast hash filter. 593 */ 594static void 595vr_setmulti(sc) 596 struct vr_softc *sc; 597{ 598 struct ifnet *ifp; 599 int h = 0; --- 17 unchanged lines hidden (view full) --- 617 /* first, zot all the existing hash bits */ 618 CSR_WRITE_4(sc, VR_MAR0, 0); 619 CSR_WRITE_4(sc, VR_MAR1, 0); 620 621 /* now program new ones */ 622 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 623 if (ifma->ifma_addr->sa_family != AF_LINK) 624 continue; | 564 * Program the 64-bit multicast hash filter. 565 */ 566static void 567vr_setmulti(sc) 568 struct vr_softc *sc; 569{ 570 struct ifnet *ifp; 571 int h = 0; --- 17 unchanged lines hidden (view full) --- 589 /* first, zot all the existing hash bits */ 590 CSR_WRITE_4(sc, VR_MAR0, 0); 591 CSR_WRITE_4(sc, VR_MAR1, 0); 592 593 /* now program new ones */ 594 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 595 if (ifma->ifma_addr->sa_family != AF_LINK) 596 continue; |
625 h = vr_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 597 h = ether_crc32_be(LLADDR((struct sockaddr_dl *) 598 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; |
626 if (h < 32) 627 hashes[0] |= (1 << h); 628 else 629 hashes[1] |= (1 << (h - 32)); 630 mcnt++; 631 } 632 633 if (mcnt) --- 1211 unchanged lines hidden --- | 599 if (h < 32) 600 hashes[0] |= (1 << h); 601 else 602 hashes[1] |= (1 << (h - 32)); 603 mcnt++; 604 } 605 606 if (mcnt) --- 1211 unchanged lines hidden --- |