if_ed.c (129616) | if_ed.c (130270) |
---|---|
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 --- 12 unchanged lines hidden (view full) --- 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 28#include <sys/cdefs.h> | 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 --- 12 unchanged lines hidden (view full) --- 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 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed.c 129616 2004-05-23 16:11:53Z mux $"); | 29__FBSDID("$FreeBSD: head/sys/dev/ed/if_ed.c 130270 2004-06-09 14:34:04Z naddy $"); |
30 31/* 32 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet 33 * adapters. By David Greenman, 29-April-1993 34 * 35 * Currently supports the Western Digital/SMC 8003 and 8013 series, 36 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000, 37 * and a variety of similar clones. --- 61 unchanged lines hidden (view full) --- 99static void ed_hpp_writemem (struct ed_softc *, unsigned char *, 100 /* u_short */ int, /* u_short */ int); 101static u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int); 102 103static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, long); 104 105static void ed_setrcr (struct ed_softc *); 106 | 30 31/* 32 * Device driver for National Semiconductor DS8390/WD83C690 based ethernet 33 * adapters. By David Greenman, 29-April-1993 34 * 35 * Currently supports the Western Digital/SMC 8003 and 8013 series, 36 * the SMC Elite Ultra (8216), the 3Com 3c503, the NE1000 and NE2000, 37 * and a variety of similar clones. --- 61 unchanged lines hidden (view full) --- 99static void ed_hpp_writemem (struct ed_softc *, unsigned char *, 100 /* u_short */ int, /* u_short */ int); 101static u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int); 102 103static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, long); 104 105static void ed_setrcr (struct ed_softc *); 106 |
107static uint32_t ds_mchash (const uint8_t *); 108 | |
109/* 110 * Interrupt conversion table for WD/SMC ASIC/83C584 111 */ 112static unsigned short ed_intr_val[] = { 113 9, 114 3, 115 5, 116 7, --- 3398 unchanged lines hidden (view full) --- 3515 3516 /* 3517 * Start interface. 3518 */ 3519 ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA); 3520} 3521 3522/* | 107/* 108 * Interrupt conversion table for WD/SMC ASIC/83C584 109 */ 110static unsigned short ed_intr_val[] = { 111 9, 112 3, 113 5, 114 7, --- 3398 unchanged lines hidden (view full) --- 3513 3514 /* 3515 * Start interface. 3516 */ 3517 ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA); 3518} 3519 3520/* |
3523 * Compute crc for ethernet address 3524 */ 3525static uint32_t 3526ds_mchash(addr) 3527 const uint8_t *addr; 3528{ 3529#define ED_POLYNOMIAL 0x04c11db6 3530 register uint32_t crc = 0xffffffff; 3531 register int carry, idx, bit; 3532 register uint8_t data; 3533 3534 for (idx = 6; --idx >= 0;) { 3535 for (data = *addr++, bit = 8; --bit >= 0; data >>=1 ) { 3536 carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); 3537 crc <<= 1; 3538 if (carry) 3539 crc = (crc ^ ED_POLYNOMIAL) | carry; 3540 } 3541 } 3542 return crc; 3543#undef POLYNOMIAL 3544} 3545 3546/* | |
3547 * Compute the multicast address filter from the 3548 * list of multicast addresses we need to listen to. 3549 */ 3550static void 3551ds_getmcaf(sc, mcaf) 3552 struct ed_softc *sc; 3553 u_int32_t *mcaf; 3554{ 3555 register u_int32_t index; 3556 register u_char *af = (u_char *) mcaf; 3557 struct ifmultiaddr *ifma; 3558 3559 mcaf[0] = 0; 3560 mcaf[1] = 0; 3561 3562 TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) { 3563 if (ifma->ifma_addr->sa_family != AF_LINK) 3564 continue; | 3521 * Compute the multicast address filter from the 3522 * list of multicast addresses we need to listen to. 3523 */ 3524static void 3525ds_getmcaf(sc, mcaf) 3526 struct ed_softc *sc; 3527 u_int32_t *mcaf; 3528{ 3529 register u_int32_t index; 3530 register u_char *af = (u_char *) mcaf; 3531 struct ifmultiaddr *ifma; 3532 3533 mcaf[0] = 0; 3534 mcaf[1] = 0; 3535 3536 TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) { 3537 if (ifma->ifma_addr->sa_family != AF_LINK) 3538 continue; |
3565 index = ds_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) 3566 >> 26; | 3539 index = ether_crc32_be(LLADDR((struct sockaddr_dl *) 3540 ifma->ifma_addr), ETHER_ADDR_LEN) >> 26; |
3567 af[index >> 3] |= 1 << (index & 7); 3568 } 3569} | 3541 af[index >> 3] |= 1 << (index & 7); 3542 } 3543} |