if_ste.c (129878) | if_ste.c (130270) |
---|---|
1/* 2 * Copyright (c) 1997, 1998, 1999 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, 1999 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_ste.c 129878 2004-05-30 20:00:41Z phk $"); | 34__FBSDID("$FreeBSD: head/sys/pci/if_ste.c 130270 2004-06-09 14:34:04Z naddy $"); |
35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/sockio.h> 39#include <sys/mbuf.h> 40#include <sys/malloc.h> 41#include <sys/kernel.h> 42#include <sys/module.h> --- 74 unchanged lines hidden (view full) --- 117static int ste_mii_writereg (struct ste_softc *, struct ste_mii_frame *); 118static int ste_miibus_readreg (device_t, int, int); 119static int ste_miibus_writereg (device_t, int, int, int); 120static void ste_miibus_statchg (device_t); 121 122static int ste_eeprom_wait (struct ste_softc *); 123static int ste_read_eeprom (struct ste_softc *, caddr_t, int, int, int); 124static void ste_wait (struct ste_softc *); | 35 36#include <sys/param.h> 37#include <sys/systm.h> 38#include <sys/sockio.h> 39#include <sys/mbuf.h> 40#include <sys/malloc.h> 41#include <sys/kernel.h> 42#include <sys/module.h> --- 74 unchanged lines hidden (view full) --- 117static int ste_mii_writereg (struct ste_softc *, struct ste_mii_frame *); 118static int ste_miibus_readreg (device_t, int, int); 119static int ste_miibus_writereg (device_t, int, int, int); 120static void ste_miibus_statchg (device_t); 121 122static int ste_eeprom_wait (struct ste_softc *); 123static int ste_read_eeprom (struct ste_softc *, caddr_t, int, int, int); 124static void ste_wait (struct ste_softc *); |
125static u_int8_t ste_calchash (caddr_t); | |
126static void ste_setmulti (struct ste_softc *); 127static int ste_init_rx_list (struct ste_softc *); 128static void ste_init_tx_list (struct ste_softc *); 129 130#ifdef STE_USEIOSPACE 131#define STE_RES SYS_RES_IOPORT 132#define STE_RID STE_PCI_LOIO 133#else --- 421 unchanged lines hidden (view full) --- 555 *ptr = ntohs(word); 556 else 557 *ptr = word; 558 } 559 560 return(err ? 1 : 0); 561} 562 | 125static void ste_setmulti (struct ste_softc *); 126static int ste_init_rx_list (struct ste_softc *); 127static void ste_init_tx_list (struct ste_softc *); 128 129#ifdef STE_USEIOSPACE 130#define STE_RES SYS_RES_IOPORT 131#define STE_RID STE_PCI_LOIO 132#else --- 421 unchanged lines hidden (view full) --- 554 *ptr = ntohs(word); 555 else 556 *ptr = word; 557 } 558 559 return(err ? 1 : 0); 560} 561 |
563static u_int8_t 564ste_calchash(addr) 565 caddr_t addr; 566{ 567 568 u_int32_t crc, carry; 569 int i, j; 570 u_int8_t c; 571 572 /* Compute CRC for the address value. */ 573 crc = 0xFFFFFFFF; /* initial value */ 574 575 for (i = 0; i < 6; i++) { 576 c = *(addr + i); 577 for (j = 0; j < 8; j++) { 578 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); 579 crc <<= 1; 580 c >>= 1; 581 if (carry) 582 crc = (crc ^ 0x04c11db6) | carry; 583 } 584 } 585 586 /* return the filter bit position */ 587 return(crc & 0x0000003F); 588} 589 | |
590static void 591ste_setmulti(sc) 592 struct ste_softc *sc; 593{ 594 struct ifnet *ifp; 595 int h = 0; 596 u_int32_t hashes[2] = { 0, 0 }; 597 struct ifmultiaddr *ifma; --- 10 unchanged lines hidden (view full) --- 608 CSR_WRITE_2(sc, STE_MAR1, 0); 609 CSR_WRITE_2(sc, STE_MAR2, 0); 610 CSR_WRITE_2(sc, STE_MAR3, 0); 611 612 /* now program new ones */ 613 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 614 if (ifma->ifma_addr->sa_family != AF_LINK) 615 continue; | 562static void 563ste_setmulti(sc) 564 struct ste_softc *sc; 565{ 566 struct ifnet *ifp; 567 int h = 0; 568 u_int32_t hashes[2] = { 0, 0 }; 569 struct ifmultiaddr *ifma; --- 10 unchanged lines hidden (view full) --- 580 CSR_WRITE_2(sc, STE_MAR1, 0); 581 CSR_WRITE_2(sc, STE_MAR2, 0); 582 CSR_WRITE_2(sc, STE_MAR3, 0); 583 584 /* now program new ones */ 585 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 586 if (ifma->ifma_addr->sa_family != AF_LINK) 587 continue; |
616 h = ste_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 588 h = ether_crc32_be(LLADDR((struct sockaddr_dl *) 589 ifma->ifma_addr), ETHER_ADDR_LEN) & 0x3F; |
617 if (h < 32) 618 hashes[0] |= (1 << h); 619 else 620 hashes[1] |= (1 << (h - 32)); 621 } 622 623 CSR_WRITE_2(sc, STE_MAR0, hashes[0] & 0xFFFF); 624 CSR_WRITE_2(sc, STE_MAR1, (hashes[0] >> 16) & 0xFFFF); --- 1119 unchanged lines hidden --- | 590 if (h < 32) 591 hashes[0] |= (1 << h); 592 else 593 hashes[1] |= (1 << (h - 32)); 594 } 595 596 CSR_WRITE_2(sc, STE_MAR0, hashes[0] & 0xFFFF); 597 CSR_WRITE_2(sc, STE_MAR1, (hashes[0] >> 16) & 0xFFFF); --- 1119 unchanged lines hidden --- |