if_wb.c (121816) | if_wb.c (122625) |
---|---|
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 --- 68 unchanged lines hidden (view full) --- 77 * Note: the author of the Linux driver for the Winbond chip alludes 78 * to some sort of flaw in the chip's design that seems to mandate some 79 * drastic workaround which signigicantly impairs transmit performance. 80 * I have no idea what he's on about: transmit performance with all 81 * three of my test boards seems fine. 82 */ 83 84#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 --- 68 unchanged lines hidden (view full) --- 77 * Note: the author of the Linux driver for the Winbond chip alludes 78 * to some sort of flaw in the chip's design that seems to mandate some 79 * drastic workaround which signigicantly impairs transmit performance. 80 * I have no idea what he's on about: transmit performance with all 81 * three of my test boards seems fine. 82 */ 83 84#include <sys/cdefs.h> |
85__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 121816 2003-10-31 18:32:15Z brooks $"); | 85__FBSDID("$FreeBSD: head/sys/pci/if_wb.c 122625 2003-11-13 20:55:53Z obrien $"); |
86 87#include "opt_bdg.h" 88 89#include <sys/param.h> 90#include <sys/systm.h> 91#include <sys/sockio.h> 92#include <sys/mbuf.h> 93#include <sys/malloc.h> --- 76 unchanged lines hidden (view full) --- 170static void wb_eeprom_getword (struct wb_softc *, int, u_int16_t *); 171static void wb_read_eeprom (struct wb_softc *, caddr_t, int, int, int); 172static void wb_mii_sync (struct wb_softc *); 173static void wb_mii_send (struct wb_softc *, u_int32_t, int); 174static int wb_mii_readreg (struct wb_softc *, struct wb_mii_frame *); 175static int wb_mii_writereg (struct wb_softc *, struct wb_mii_frame *); 176 177static void wb_setcfg (struct wb_softc *, u_int32_t); | 86 87#include "opt_bdg.h" 88 89#include <sys/param.h> 90#include <sys/systm.h> 91#include <sys/sockio.h> 92#include <sys/mbuf.h> 93#include <sys/malloc.h> --- 76 unchanged lines hidden (view full) --- 170static void wb_eeprom_getword (struct wb_softc *, int, u_int16_t *); 171static void wb_read_eeprom (struct wb_softc *, caddr_t, int, int, int); 172static void wb_mii_sync (struct wb_softc *); 173static void wb_mii_send (struct wb_softc *, u_int32_t, int); 174static int wb_mii_readreg (struct wb_softc *, struct wb_mii_frame *); 175static int wb_mii_writereg (struct wb_softc *, struct wb_mii_frame *); 176 177static void wb_setcfg (struct wb_softc *, u_int32_t); |
178static u_int8_t wb_calchash (caddr_t); | 178static u_int32_t wb_mchash (caddr_t); |
179static void wb_setmulti (struct wb_softc *); 180static void wb_reset (struct wb_softc *); 181static void wb_fixmedia (struct wb_softc *); 182static int wb_list_rx_init (struct wb_softc *); 183static int wb_list_tx_init (struct wb_softc *); 184 185static int wb_miibus_readreg (device_t, int, int); 186static int wb_miibus_writereg (device_t, int, int, int); --- 395 unchanged lines hidden (view full) --- 582 WB_LOCK(sc); 583 mii = device_get_softc(sc->wb_miibus); 584 wb_setcfg(sc, mii->mii_media_active); 585 WB_UNLOCK(sc); 586 587 return; 588} 589 | 179static void wb_setmulti (struct wb_softc *); 180static void wb_reset (struct wb_softc *); 181static void wb_fixmedia (struct wb_softc *); 182static int wb_list_rx_init (struct wb_softc *); 183static int wb_list_tx_init (struct wb_softc *); 184 185static int wb_miibus_readreg (device_t, int, int); 186static int wb_miibus_writereg (device_t, int, int, int); --- 395 unchanged lines hidden (view full) --- 582 WB_LOCK(sc); 583 mii = device_get_softc(sc->wb_miibus); 584 wb_setcfg(sc, mii->mii_media_active); 585 WB_UNLOCK(sc); 586 587 return; 588} 589 |
590static u_int8_t wb_calchash(addr) 591 caddr_t addr; | 590static u_int32_t 591wb_mchash(addr) 592 caddr_t addr; |
592{ | 593{ |
593 u_int32_t crc, carry; 594 int i, j; 595 u_int8_t c; | 594 u_int32_t crc, carry; 595 int idx, bit; 596 u_int8_t data; |
596 597 /* Compute CRC for the address value. */ 598 crc = 0xFFFFFFFF; /* initial value */ 599 | 597 598 /* Compute CRC for the address value. */ 599 crc = 0xFFFFFFFF; /* initial value */ 600 |
600 for (i = 0; i < 6; i++) { 601 c = *(addr + i); 602 for (j = 0; j < 8; j++) { 603 carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); | 601 for (idx = 0; idx < 6; idx++) { 602 for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { 603 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
604 crc <<= 1; | 604 crc <<= 1; |
605 c >>= 1; | |
606 if (carry) 607 crc = (crc ^ 0x04c11db6) | carry; 608 } 609 } 610 611 /* 612 * return the filter bit position 613 * Note: I arrived at the following nonsense --- 33 unchanged lines hidden (view full) --- 647 /* first, zot all the existing hash bits */ 648 CSR_WRITE_4(sc, WB_MAR0, 0); 649 CSR_WRITE_4(sc, WB_MAR1, 0); 650 651 /* now program new ones */ 652 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 653 if (ifma->ifma_addr->sa_family != AF_LINK) 654 continue; | 605 if (carry) 606 crc = (crc ^ 0x04c11db6) | carry; 607 } 608 } 609 610 /* 611 * return the filter bit position 612 * Note: I arrived at the following nonsense --- 33 unchanged lines hidden (view full) --- 646 /* first, zot all the existing hash bits */ 647 CSR_WRITE_4(sc, WB_MAR0, 0); 648 CSR_WRITE_4(sc, WB_MAR1, 0); 649 650 /* now program new ones */ 651 TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { 652 if (ifma->ifma_addr->sa_family != AF_LINK) 653 continue; |
655 h = wb_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); | 654 h = wb_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); |
656 if (h < 32) 657 hashes[0] |= (1 << h); 658 else 659 hashes[1] |= (1 << (h - 32)); 660 mcnt++; 661 } 662 663 if (mcnt) --- 1227 unchanged lines hidden --- | 655 if (h < 32) 656 hashes[0] |= (1 << h); 657 else 658 hashes[1] |= (1 << (h - 32)); 659 mcnt++; 660 } 661 662 if (mcnt) --- 1227 unchanged lines hidden --- |