if_ste.c (121816) | if_ste.c (122625) |
---|---|
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 121816 2003-10-31 18:32:15Z brooks $"); | 34__FBSDID("$FreeBSD: head/sys/pci/if_ste.c 122625 2003-11-13 20:55:53Z obrien $"); |
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/socket.h> --- 71 unchanged lines hidden (view full) --- 114static int ste_mii_writereg (struct ste_softc *, struct ste_mii_frame *); 115static int ste_miibus_readreg (device_t, int, int); 116static int ste_miibus_writereg (device_t, int, int, int); 117static void ste_miibus_statchg (device_t); 118 119static int ste_eeprom_wait (struct ste_softc *); 120static int ste_read_eeprom (struct ste_softc *, caddr_t, int, int, int); 121static 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/socket.h> --- 71 unchanged lines hidden (view full) --- 114static int ste_mii_writereg (struct ste_softc *, struct ste_mii_frame *); 115static int ste_miibus_readreg (device_t, int, int); 116static int ste_miibus_writereg (device_t, int, int, int); 117static void ste_miibus_statchg (device_t); 118 119static int ste_eeprom_wait (struct ste_softc *); 120static int ste_read_eeprom (struct ste_softc *, caddr_t, int, int, int); 121static void ste_wait (struct ste_softc *); |
122static u_int8_t ste_calchash (caddr_t); | 122static u_int32_t ste_mchash (caddr_t); |
123static void ste_setmulti (struct ste_softc *); 124static int ste_init_rx_list (struct ste_softc *); 125static void ste_init_tx_list (struct ste_softc *); 126 127#ifdef STE_USEIOSPACE 128#define STE_RES SYS_RES_IOPORT 129#define STE_RID STE_PCI_LOIO 130#else --- 416 unchanged lines hidden (view full) --- 547 *ptr = ntohs(word); 548 else 549 *ptr = word; 550 } 551 552 return(err ? 1 : 0); 553} 554 | 123static void ste_setmulti (struct ste_softc *); 124static int ste_init_rx_list (struct ste_softc *); 125static void ste_init_tx_list (struct ste_softc *); 126 127#ifdef STE_USEIOSPACE 128#define STE_RES SYS_RES_IOPORT 129#define STE_RID STE_PCI_LOIO 130#else --- 416 unchanged lines hidden (view full) --- 547 *ptr = ntohs(word); 548 else 549 *ptr = word; 550 } 551 552 return(err ? 1 : 0); 553} 554 |
555static u_int8_t 556ste_calchash(addr) 557 caddr_t addr; | 555static u_int32_t 556ste_mchash(addr) 557 caddr_t addr; |
558{ 559 | 558{ 559 |
560 u_int32_t crc, carry; 561 int i, j; 562 u_int8_t c; | 560 u_int32_t crc, carry; 561 int idx, bit; 562 u_int8_t data; |
563 564 /* Compute CRC for the address value. */ 565 crc = 0xFFFFFFFF; /* initial value */ 566 | 563 564 /* Compute CRC for the address value. */ 565 crc = 0xFFFFFFFF; /* initial value */ 566 |
567 for (i = 0; i < 6; i++) { 568 c = *(addr + i); 569 for (j = 0; j < 8; j++) { 570 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 567 for (idx = 0; idx < 6; idx++) { 568 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 569 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
571 crc <<= 1; | 570 crc <<= 1; |
572 c >>= 1; | |
573 if (carry) 574 crc = (crc ^ 0x04c11db6) | carry; 575 } 576 } 577 578 /* return the filter bit position */ 579 return(crc & 0x0000003F); 580} --- 19 unchanged lines hidden (view full) --- 600 CSR_WRITE_2(sc, STE_MAR1, 0); 601 CSR_WRITE_2(sc, STE_MAR2, 0); 602 CSR_WRITE_2(sc, STE_MAR3, 0); 603 604 /* now program new ones */ 605 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 606 if (ifma->ifma_addr->sa_family != AF_LINK) 607 continue; | 571 if (carry) 572 crc = (crc ^ 0x04c11db6) | carry; 573 } 574 } 575 576 /* return the filter bit position */ 577 return(crc & 0x0000003F); 578} --- 19 unchanged lines hidden (view full) --- 598 CSR_WRITE_2(sc, STE_MAR1, 0); 599 CSR_WRITE_2(sc, STE_MAR2, 0); 600 CSR_WRITE_2(sc, STE_MAR3, 0); 601 602 /* now program new ones */ 603 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 604 if (ifma->ifma_addr->sa_family != AF_LINK) 605 continue; |
608 h = ste_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 606 h = ste_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
609 if (h < 32) 610 hashes[0] |= (1 << h); 611 else 612 hashes[1] |= (1 << (h - 32)); 613 } 614 615 CSR_WRITE_2(sc, STE_MAR0, hashes[0] & 0xFFFF); 616 CSR_WRITE_2(sc, STE_MAR1, (hashes[0] >> 16) & 0xFFFF); --- 1029 unchanged lines hidden --- | 607 if (h < 32) 608 hashes[0] |= (1 << h); 609 else 610 hashes[1] |= (1 << (h - 32)); 611 } 612 613 CSR_WRITE_2(sc, STE_MAR0, hashes[0] & 0xFFFF); 614 CSR_WRITE_2(sc, STE_MAR1, (hashes[0] >> 16) & 0xFFFF); --- 1029 unchanged lines hidden --- |