if_lge.c (121816) | if_lge.c (122625) |
---|---|
1/* 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2000, 2001 4 * Bill Paul <william.paul@windriver.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 <william.paul@windriver.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/lge/if_lge.c 121816 2003-10-31 18:32:15Z brooks $"); | 35__FBSDID("$FreeBSD: head/sys/dev/lge/if_lge.c 122625 2003-11-13 20:55:53Z obrien $"); |
36 37/* 38 * Level 1 LXT1001 gigabit ethernet driver for FreeBSD. Public 39 * documentation not available, but ask me nicely. 40 * 41 * The Level 1 chip is used on some D-Link, SMC and Addtron NICs. 42 * It's a 64-bit PCI part that supports TCP/IP checksum offload, 43 * VLAN tagging/insertion, GMII and TBI (1000baseX) ports. There --- 21 unchanged lines hidden (view full) --- 65 * - Beny Chen at D-Link, for actually sending it to me 66 * - Brad Short and Keith Alexis at SMC, for sending me sample 67 * SMC9462SX and SMC9462TX adapters for testing 68 * - Paul Saab at Y!, for not killing me (though it remains to be seen 69 * if in fact he did me much of a favor) 70 */ 71 72#include <sys/cdefs.h> | 36 37/* 38 * Level 1 LXT1001 gigabit ethernet driver for FreeBSD. Public 39 * documentation not available, but ask me nicely. 40 * 41 * The Level 1 chip is used on some D-Link, SMC and Addtron NICs. 42 * It's a 64-bit PCI part that supports TCP/IP checksum offload, 43 * VLAN tagging/insertion, GMII and TBI (1000baseX) ports. There --- 21 unchanged lines hidden (view full) --- 65 * - Beny Chen at D-Link, for actually sending it to me 66 * - Brad Short and Keith Alexis at SMC, for sending me sample 67 * SMC9462SX and SMC9462TX adapters for testing 68 * - Paul Saab at Y!, for not killing me (though it remains to be seen 69 * if in fact he did me much of a favor) 70 */ 71 72#include <sys/cdefs.h> |
73__FBSDID("$FreeBSD: head/sys/dev/lge/if_lge.c 121816 2003-10-31 18:32:15Z brooks $"); | 73__FBSDID("$FreeBSD: head/sys/dev/lge/if_lge.c 122625 2003-11-13 20:55:53Z obrien $"); |
74 75#include <sys/param.h> 76#include <sys/systm.h> 77#include <sys/sockio.h> 78#include <sys/mbuf.h> 79#include <sys/malloc.h> 80#include <sys/kernel.h> 81#include <sys/socket.h> --- 65 unchanged lines hidden (view full) --- 147static void lge_eeprom_getword(struct lge_softc *, int, u_int16_t *); 148static void lge_read_eeprom(struct lge_softc *, caddr_t, int, int, int); 149 150static int lge_miibus_readreg(device_t, int, int); 151static int lge_miibus_writereg(device_t, int, int, int); 152static void lge_miibus_statchg(device_t); 153 154static void lge_setmulti(struct lge_softc *); | 74 75#include <sys/param.h> 76#include <sys/systm.h> 77#include <sys/sockio.h> 78#include <sys/mbuf.h> 79#include <sys/malloc.h> 80#include <sys/kernel.h> 81#include <sys/socket.h> --- 65 unchanged lines hidden (view full) --- 147static void lge_eeprom_getword(struct lge_softc *, int, u_int16_t *); 148static void lge_read_eeprom(struct lge_softc *, caddr_t, int, int, int); 149 150static int lge_miibus_readreg(device_t, int, int); 151static int lge_miibus_writereg(device_t, int, int, int); 152static void lge_miibus_statchg(device_t); 153 154static void lge_setmulti(struct lge_softc *); |
155static u_int32_t lge_crc(struct lge_softc *, caddr_t); | 155static u_int32_t lge_mchash(caddr_t); |
156static void lge_reset(struct lge_softc *); 157static int lge_list_rx_init(struct lge_softc *); 158static int lge_list_tx_init(struct lge_softc *); 159 160#ifdef LGE_USEIOSPACE 161#define LGE_RES SYS_RES_IOPORT 162#define LGE_RID LGE_PCI_LOIO 163#else --- 202 unchanged lines hidden (view full) --- 366 } else { 367 LGE_CLRBIT(sc, LGE_GMIIMODE, LGE_GMIIMODE_FDX); 368 } 369 370 return; 371} 372 373static u_int32_t | 156static void lge_reset(struct lge_softc *); 157static int lge_list_rx_init(struct lge_softc *); 158static int lge_list_tx_init(struct lge_softc *); 159 160#ifdef LGE_USEIOSPACE 161#define LGE_RES SYS_RES_IOPORT 162#define LGE_RID LGE_PCI_LOIO 163#else --- 202 unchanged lines hidden (view full) --- 366 } else { 367 LGE_CLRBIT(sc, LGE_GMIIMODE, LGE_GMIIMODE_FDX); 368 } 369 370 return; 371} 372 373static u_int32_t |
374lge_crc(sc, addr) 375 struct lge_softc *sc; 376 caddr_t addr; | 374lge_mchash(addr) 375 caddr_t addr; |
377{ | 376{ |
378 u_int32_t crc, carry; 379 int i, j; 380 u_int8_t c; | 377 u_int32_t crc, carry; 378 int idx, bit; 379 u_int8_t data; |
381 382 /* Compute CRC for the address value. */ 383 crc = 0xFFFFFFFF; /* initial value */ 384 | 380 381 /* Compute CRC for the address value. */ 382 crc = 0xFFFFFFFF; /* initial value */ 383 |
385 for (i = 0; i < 6; i++) { 386 c = *(addr + i); 387 for (j = 0; j < 8; j++) { 388 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 384 for (idx = 0; idx < 6; idx++) { 385 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 386 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
389 crc <<= 1; | 387 crc <<= 1; |
390 c >>= 1; | |
391 if (carry) 392 crc = (crc ^ 0x04c11db6) | carry; 393 } 394 } 395 396 /* 397 * return the filter bit position 398 */ --- 22 unchanged lines hidden (view full) --- 421 /* first, zot all the existing hash bits */ 422 CSR_WRITE_4(sc, LGE_MAR0, 0); 423 CSR_WRITE_4(sc, LGE_MAR1, 0); 424 425 /* now program new ones */ 426 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 427 if (ifma->ifma_addr->sa_family != AF_LINK) 428 continue; | 388 if (carry) 389 crc = (crc ^ 0x04c11db6) | carry; 390 } 391 } 392 393 /* 394 * return the filter bit position 395 */ --- 22 unchanged lines hidden (view full) --- 418 /* first, zot all the existing hash bits */ 419 CSR_WRITE_4(sc, LGE_MAR0, 0); 420 CSR_WRITE_4(sc, LGE_MAR1, 0); 421 422 /* now program new ones */ 423 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 424 if (ifma->ifma_addr->sa_family != AF_LINK) 425 continue; |
429 h = lge_crc(sc, LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 426 h = lge_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
430 if (h < 32) 431 hashes[0] |= (1 << h); 432 else 433 hashes[1] |= (1 << (h - 32)); 434 } 435 436 CSR_WRITE_4(sc, LGE_MAR0, hashes[0]); 437 CSR_WRITE_4(sc, LGE_MAR1, hashes[1]); --- 1184 unchanged lines hidden --- | 427 if (h < 32) 428 hashes[0] |= (1 << h); 429 else 430 hashes[1] |= (1 << (h - 32)); 431 } 432 433 CSR_WRITE_4(sc, LGE_MAR0, hashes[0]); 434 CSR_WRITE_4(sc, LGE_MAR1, hashes[1]); --- 1184 unchanged lines hidden --- |