if_ed.c (121816) | if_ed.c (122625) |
---|---|
1/* 2 * Copyright (c) 1995, David Greenman 3 * 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 --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * | 1/* 2 * Copyright (c) 1995, David Greenman 3 * 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 --- 10 unchanged lines hidden (view full) --- 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * |
27 * $FreeBSD: head/sys/dev/ed/if_ed.c 121816 2003-10-31 18:32:15Z brooks $ | 27 * $FreeBSD: head/sys/dev/ed/if_ed.c 122625 2003-11-13 20:55:53Z obrien $ |
28 */ 29 30/* 31 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet 32 * adapters. By David Greenman, 29-April-1993 33 * 34 * Currently supports the Western Digital/SMC 8003 and 8013 series, 35 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000, --- 62 unchanged lines hidden (view full) --- 98static void ed_hpp_writemem (struct ed_softc *, unsigned char *, 99 /* u_short */ int, /* u_short */ int); 100static u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int); 101 102static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, int); 103 104static void ed_setrcr (struct ed_softc *); 105 | 28 */ 29 30/* 31 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet 32 * adapters. By David Greenman, 29-April-1993 33 * 34 * Currently supports the Western Digital/SMC 8003 and 8013 series, 35 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000, --- 62 unchanged lines hidden (view full) --- 98static void ed_hpp_writemem (struct ed_softc *, unsigned char *, 99 /* u_short */ int, /* u_short */ int); 100static u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int); 101 102static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, int); 103 104static void ed_setrcr (struct ed_softc *); 105 |
106static u_int32_t ds_crc (u_char *ep); | 106static u_int32_t ds_mchash (caddr_t addr); |
107 108/* 109 * Interrupt conversion table for WD/SMC ASIC/83C584 110 */ 111static unsigned short ed_intr_val[] = { 112 9, 113 3, 114 5, --- 3411 unchanged lines hidden (view full) --- 3526 */ 3527 ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA); 3528} 3529 3530/* 3531 * Compute crc for ethernet address 3532 */ 3533static u_int32_t | 107 108/* 109 * Interrupt conversion table for WD/SMC ASIC/83C584 110 */ 111static unsigned short ed_intr_val[] = { 112 9, 113 3, 114 5, --- 3411 unchanged lines hidden (view full) --- 3526 */ 3527 ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA); 3528} 3529 3530/* 3531 * Compute crc for ethernet address 3532 */ 3533static u_int32_t |
3534ds_crc(ep) 3535 u_char *ep; | 3534ds_mchash(addr) 3535 caddr_t addr; |
3536{ | 3536{ |
3537#define POLYNOMIAL 0x04c11db6 | 3537#define ED_POLYNOMIAL 0x04c11db6 |
3538 register u_int32_t crc = 0xffffffff; | 3538 register u_int32_t crc = 0xffffffff; |
3539 register int carry, i, j; 3540 register u_char b; | 3539 register int carry, idx, bit; 3540 register u_char data; |
3541 | 3541 |
3542 for (i = 6; --i >= 0;) { 3543 b = *ep++; 3544 for (j = 8; --j >= 0;) { 3545 carry = ((crc & 0x80000000) ? 1 : 0) ^ (b & 0x01); | 3542 for (idx = 6; --idx >= 0;) { 3543 for (data = *addr++, bit = 8; --bit >= 0; data >>=1 ) { 3544 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
3546 crc <<= 1; | 3545 crc <<= 1; |
3547 b >>= 1; | |
3548 if (carry) | 3546 if (carry) |
3549 crc = (crc ^ POLYNOMIAL) | carry; | 3547 crc = (crc ^ ED_POLYNOMIAL) | carry; |
3550 } 3551 } 3552 return crc; 3553#undef POLYNOMIAL 3554} 3555 3556/* 3557 * Compute the multicast address filter from the --- 9 unchanged lines hidden (view full) --- 3567 struct ifmultiaddr *ifma; 3568 3569 mcaf[0] = 0; 3570 mcaf[1] = 0; 3571 3572 TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) { 3573 if (ifma->ifma_addr->sa_family != AF_LINK) 3574 continue; | 3548 } 3549 } 3550 return crc; 3551#undef POLYNOMIAL 3552} 3553 3554/* 3555 * Compute the multicast address filter from the --- 9 unchanged lines hidden (view full) --- 3565 struct ifmultiaddr *ifma; 3566 3567 mcaf[0] = 0; 3568 mcaf[1] = 0; 3569 3570 TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) { 3571 if (ifma->ifma_addr->sa_family != AF_LINK) 3572 continue; |
3575 index = ds_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) | 3573 index = ds_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) |
3576 >> 26; 3577 af[index >> 3] |= 1 << (index & 7); 3578 } 3579} | 3574 >> 26; 3575 af[index >> 3] |= 1 << (index & 7); 3576 } 3577} |