if_nge.c (121816) | if_nge.c (122625) |
---|---|
1/* 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2000, 2001 4 * Bill Paul <wpaul@bsdi.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 18 unchanged lines hidden (view full) --- 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2000, 2001 4 * Bill Paul <wpaul@bsdi.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 18 unchanged lines hidden (view full) --- 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/dev/nge/if_nge.c 121816 2003-10-31 18:32:15Z brooks $"); | 35__FBSDID("$FreeBSD: head/sys/dev/nge/if_nge.c 122625 2003-11-13 20:55:53Z obrien $"); |
36 37/* 38 * National Semiconductor DP83820/DP83821 gigabit ethernet driver 39 * for FreeBSD. Datasheets are available from: 40 * 41 * http://www.national.com/ds/DP/DP83820.pdf 42 * http://www.national.com/ds/DP/DP83821.pdf 43 * --- 40 unchanged lines hidden (view full) --- 84 * TX checksum offload enabled and you transmit attempt to transmit a 85 * frame larger than 8170 bytes, the transmitter will wedge. 86 * 87 * To work around the latter problem, TX checksum offload is disabled 88 * if the user selects an MTU larger than 8152 (8170 - 18). 89 */ 90 91#include <sys/cdefs.h> | 36 37/* 38 * National Semiconductor DP83820/DP83821 gigabit ethernet driver 39 * for FreeBSD. Datasheets are available from: 40 * 41 * http://www.national.com/ds/DP/DP83820.pdf 42 * http://www.national.com/ds/DP/DP83821.pdf 43 * --- 40 unchanged lines hidden (view full) --- 84 * TX checksum offload enabled and you transmit attempt to transmit a 85 * frame larger than 8170 bytes, the transmitter will wedge. 86 * 87 * To work around the latter problem, TX checksum offload is disabled 88 * if the user selects an MTU larger than 8152 (8170 - 18). 89 */ 90 91#include <sys/cdefs.h> |
92__FBSDID("$FreeBSD: head/sys/dev/nge/if_nge.c 121816 2003-10-31 18:32:15Z brooks $"); | 92__FBSDID("$FreeBSD: head/sys/dev/nge/if_nge.c 122625 2003-11-13 20:55:53Z obrien $"); |
93 94#include <sys/param.h> 95#include <sys/systm.h> 96#include <sys/sockio.h> 97#include <sys/mbuf.h> 98#include <sys/malloc.h> 99#include <sys/kernel.h> 100#include <sys/socket.h> --- 81 unchanged lines hidden (view full) --- 182static int nge_mii_readreg(struct nge_softc *, struct nge_mii_frame *); 183static int nge_mii_writereg(struct nge_softc *, struct nge_mii_frame *); 184 185static int nge_miibus_readreg(device_t, int, int); 186static int nge_miibus_writereg(device_t, int, int, int); 187static void nge_miibus_statchg(device_t); 188 189static void nge_setmulti(struct nge_softc *); | 93 94#include <sys/param.h> 95#include <sys/systm.h> 96#include <sys/sockio.h> 97#include <sys/mbuf.h> 98#include <sys/malloc.h> 99#include <sys/kernel.h> 100#include <sys/socket.h> --- 81 unchanged lines hidden (view full) --- 182static int nge_mii_readreg(struct nge_softc *, struct nge_mii_frame *); 183static int nge_mii_writereg(struct nge_softc *, struct nge_mii_frame *); 184 185static int nge_miibus_readreg(device_t, int, int); 186static int nge_miibus_writereg(device_t, int, int, int); 187static void nge_miibus_statchg(device_t); 188 189static void nge_setmulti(struct nge_softc *); |
190static u_int32_t nge_crc(struct nge_softc *, caddr_t); | 190static u_int32_t nge_mchash(caddr_t); |
191static void nge_reset(struct nge_softc *); 192static int nge_list_rx_init(struct nge_softc *); 193static int nge_list_tx_init(struct nge_softc *); 194 195#ifdef NGE_USEIOSPACE 196#define NGE_RES SYS_RES_IOPORT 197#define NGE_RID NGE_PCI_LOIO 198#else --- 471 unchanged lines hidden (view full) --- 670 } else { 671 NGE_CLRBIT(sc, NGE_CFG, NGE_CFG_MODE_1000); 672 } 673 } 674 return; 675} 676 677static u_int32_t | 191static void nge_reset(struct nge_softc *); 192static int nge_list_rx_init(struct nge_softc *); 193static int nge_list_tx_init(struct nge_softc *); 194 195#ifdef NGE_USEIOSPACE 196#define NGE_RES SYS_RES_IOPORT 197#define NGE_RID NGE_PCI_LOIO 198#else --- 471 unchanged lines hidden (view full) --- 670 } else { 671 NGE_CLRBIT(sc, NGE_CFG, NGE_CFG_MODE_1000); 672 } 673 } 674 return; 675} 676 677static u_int32_t |
678nge_crc(sc, addr) 679 struct nge_softc *sc; 680 caddr_t addr; | 678nge_mchash(addr) 679 caddr_t addr; |
681{ | 680{ |
682 u_int32_t crc, carry; 683 int i, j; 684 u_int8_t c; | 681 u_int32_t crc, carry; 682 int idx, bit; 683 u_int8_t data; |
685 686 /* Compute CRC for the address value. */ 687 crc = 0xFFFFFFFF; /* initial value */ 688 | 684 685 /* Compute CRC for the address value. */ 686 crc = 0xFFFFFFFF; /* initial value */ 687 |
689 for (i = 0; i < 6; i++) { 690 c = *(addr + i); 691 for (j = 0; j < 8; j++) { 692 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 688 for (idx = 0; idx < 6; idx++) { 689 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 690 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
693 crc <<= 1; | 691 crc <<= 1; |
694 c >>= 1; | |
695 if (carry) 696 crc = (crc ^ 0x04c11db6) | carry; 697 } 698 } 699 700 /* 701 * return the filter bit position 702 */ --- 41 unchanged lines hidden (view full) --- 744 * From the 11 bits returned by the crc routine, the top 7 745 * bits represent the 16-bit word in the mcast hash table 746 * that needs to be updated, and the lower 4 bits represent 747 * which bit within that byte needs to be set. 748 */ 749 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 750 if (ifma->ifma_addr->sa_family != AF_LINK) 751 continue; | 692 if (carry) 693 crc = (crc ^ 0x04c11db6) | carry; 694 } 695 } 696 697 /* 698 * return the filter bit position 699 */ --- 41 unchanged lines hidden (view full) --- 741 * From the 11 bits returned by the crc routine, the top 7 742 * bits represent the 16-bit word in the mcast hash table 743 * that needs to be updated, and the lower 4 bits represent 744 * which bit within that byte needs to be set. 745 */ 746 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 747 if (ifma->ifma_addr->sa_family != AF_LINK) 748 continue; |
752 h = nge_crc(sc, LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 749 h = nge_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
753 index = (h >> 4) & 0x7F; 754 bit = h & 0xF; 755 CSR_WRITE_4(sc, NGE_RXFILT_CTL, 756 NGE_FILTADDR_MCAST_LO + (index * 2)); 757 NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit)); 758 } 759 760 CSR_WRITE_4(sc, NGE_RXFILT_CTL, filtsave); --- 1528 unchanged lines hidden --- | 750 index = (h >> 4) & 0x7F; 751 bit = h & 0xF; 752 CSR_WRITE_4(sc, NGE_RXFILT_CTL, 753 NGE_FILTADDR_MCAST_LO + (index * 2)); 754 NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit)); 755 } 756 757 CSR_WRITE_4(sc, NGE_RXFILT_CTL, filtsave); --- 1528 unchanged lines hidden --- |