|
|
| version 1.9, 2004/02/08 06:47:35 | version 1.10, 2004/02/13 21:15:12 |
|---|---|
| Line 24 | Line 24 |
| * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| * SUCH DAMAGE. | * SUCH DAMAGE. |
| * | * |
| * $FreeBSD: src/sys/dev/ed/if_ed.c,v 1.173.2.14 2003/12/24 17:02:00 shiba Exp $ | * $FreeBSD: src/sys/dev/ed/if_ed.c,v 1.224 2003/12/08 07:54:12 obrien Exp $ |
| * $DragonFly$ | * $DragonFly$ |
| */ | */ |
| Line 38 | Line 38 |
| * | * |
| */ | */ |
| #include "opt_ed.h" | |
| #include <sys/param.h> | #include <sys/param.h> |
| #include <sys/systm.h> | #include <sys/systm.h> |
| #include <sys/sockio.h> | #include <sys/sockio.h> |
| Line 60 | Line 62 |
| #include <net/if_mib.h> | #include <net/if_mib.h> |
| #include <net/if_media.h> | #include <net/if_media.h> |
| #include "../mii_layer/mii.h" | #ifndef ED_NO_MIIBUS |
| #include "../mii_layer/miivar.h" | #include <dev/netif/mii_layer/mii.h> |
| #include <dev/netif/mii_layer/miivar.h> | |
| #endif | |
| #include <net/bpf.h> | #include <net/bpf.h> |
| #include "opt_bdg.h" | #include "opt_bdg.h" |
| #include <net/bridge/bridge.h> | #include <net/bridge/bridge.h> |
| #include <machine/clock.h> | |
| #include <machine/md_var.h> | #include <machine/md_var.h> |
| #include "if_edreg.h" | #include "if_edreg.h" |
| #include "if_edvar.h" | #include "if_edvar.h" |
| devclass_t ed_devclass; | |
| static void ed_init (void *); | static void ed_init (void *); |
| static int ed_ioctl (struct ifnet *, u_long, caddr_t); | static int ed_ioctl (struct ifnet *, u_long, caddr_t); |
| static void ed_start (struct ifnet *); | static void ed_start (struct ifnet *); |
| static void ed_reset (struct ifnet *); | static void ed_reset (struct ifnet *); |
| static void ed_watchdog (struct ifnet *); | static void ed_watchdog (struct ifnet *); |
| #ifndef ED_NO_MIIBUS | |
| static void ed_tick (void *); | static void ed_tick (void *); |
| #endif | |
| static void ds_getmcaf (struct ed_softc *, u_int32_t *); | static void ds_getmcaf (struct ed_softc *, u_int32_t *); |
| Line 101 static u_short ed_pio_write_mbufs (struc | Line 108 static u_short ed_pio_write_mbufs (struc |
| static void ed_setrcr (struct ed_softc *); | static void ed_setrcr (struct ed_softc *); |
| static u_int32_t ds_crc (u_char *ep); | static uint32_t ds_mchash (const uint8_t *); |
| DECLARE_DUMMY_MODULE(if_ed); | DECLARE_DUMMY_MODULE(if_ed); |
| Line 569 ed_probe_WD80x3_generic(dev, flags, intr | Line 576 ed_probe_WD80x3_generic(dev, flags, intr |
| for (i = 0; i < memsize; ++i) { | for (i = 0; i < memsize; ++i) { |
| if (sc->mem_start[i]) { | if (sc->mem_start[i]) { |
| device_printf(dev, "failed to clear shared memory at %llx - check configuration\n", | device_printf(dev, "failed to clear shared memory at %llx - check configuration\n", |
| kvtop(sc->mem_start + i)); | (long long)kvtop(sc->mem_start + i)); |
| /* | /* |
| * Disable 16 bit access to shared memory | * Disable 16 bit access to shared memory |
| Line 903 ed_probe_3Com(dev, port_rid, flags) | Line 910 ed_probe_3Com(dev, port_rid, flags) |
| for (i = 0; i < memsize; ++i) | for (i = 0; i < memsize; ++i) |
| if (sc->mem_start[i]) { | if (sc->mem_start[i]) { |
| device_printf(dev, "failed to clear shared memory at %lx - check configuration\n", | device_printf(dev, "failed to clear shared memory at %llx - check configuration\n", |
| kvtop(sc->mem_start + i)); | (unsigned long long)kvtop(sc->mem_start + i)); |
| return (ENXIO); | return (ENXIO); |
| } | } |
| return (0); | return (0); |
| Line 997 ed_probe_SIC(dev, port_rid, flags) | Line 1004 ed_probe_SIC(dev, port_rid, flags) |
| if (sc->mem_start[i]) { | if (sc->mem_start[i]) { |
| device_printf(dev, "failed to clear shared memory " | device_printf(dev, "failed to clear shared memory " |
| "at %llx - check configuration\n", | "at %llx - check configuration\n", |
| kvtop(sc->mem_start + i)); | (long long)kvtop(sc->mem_start + i)); |
| return (ENXIO); | return (ENXIO); |
| } | } |
| Line 1050 ed_probe_Novell_generic(dev, flags) | Line 1057 ed_probe_Novell_generic(dev, flags) |
| /* | /* |
| * I don't know if this is necessary; probably cruft leftover from | * I don't know if this is necessary; probably cruft leftover from |
| * Clarkson packet driver code. Doesn't do a thing on the boards I've | * Clarkson packet driver code. Doesn't do a thing on the boards I've |
| * tested. -DG [note that a outb(0x84, 0) seems to work here, and is | * tested. -DG [note that an outb(0x84, 0) seems to work here, and is |
| * non-invasive...but some boards don't seem to reset and I don't have | * non-invasive...but some boards don't seem to reset and I don't have |
| * complete documentation on what the 'right' thing to do is...so we | * complete documentation on what the 'right' thing to do is...so we |
| * do the invasive thing for now. Yuck.] | * do the invasive thing for now. Yuck.] |
| Line 1545 ed_probe_HP_pclanp(dev, port_rid, flags) | Line 1552 ed_probe_HP_pclanp(dev, port_rid, flags) |
| * HP PC Lan+ : Set the physical link to use AUI or TP/TL. | * HP PC Lan+ : Set the physical link to use AUI or TP/TL. |
| */ | */ |
| void | static void |
| ed_hpp_set_physical_link(struct ed_softc *sc) | ed_hpp_set_physical_link(struct ed_softc *sc) |
| { | { |
| struct ifnet *ifp = &sc->arpcom.ac_if; | struct ifnet *ifp = &sc->arpcom.ac_if; |
| Line 1674 ed_release_resources(dev) | Line 1681 ed_release_resources(dev) |
| struct ed_softc *sc = device_get_softc(dev); | struct ed_softc *sc = device_get_softc(dev); |
| if (sc->port_res) { | if (sc->port_res) { |
| bus_deactivate_resource(dev, SYS_RES_IOPORT, | |
| sc->port_rid, sc->port_res); | |
| bus_release_resource(dev, SYS_RES_IOPORT, | bus_release_resource(dev, SYS_RES_IOPORT, |
| sc->port_rid, sc->port_res); | sc->port_rid, sc->port_res); |
| sc->port_res = 0; | sc->port_res = 0; |
| } | } |
| if (sc->mem_res) { | if (sc->mem_res) { |
| bus_deactivate_resource(dev, SYS_RES_MEMORY, | |
| sc->mem_rid, sc->mem_res); | |
| bus_release_resource(dev, SYS_RES_MEMORY, | bus_release_resource(dev, SYS_RES_MEMORY, |
| sc->mem_rid, sc->mem_res); | sc->mem_rid, sc->mem_res); |
| sc->mem_res = 0; | sc->mem_res = 0; |
| } | } |
| if (sc->irq_res) { | if (sc->irq_res) { |
| bus_deactivate_resource(dev, SYS_RES_IRQ, | |
| sc->irq_rid, sc->irq_res); | |
| bus_release_resource(dev, SYS_RES_IRQ, | bus_release_resource(dev, SYS_RES_IRQ, |
| sc->irq_rid, sc->irq_res); | sc->irq_rid, sc->irq_res); |
| sc->irq_res = 0; | sc->irq_res = 0; |
| Line 1694 ed_release_resources(dev) | Line 1707 ed_release_resources(dev) |
| * Install interface into kernel networking data structures | * Install interface into kernel networking data structures |
| */ | */ |
| int | int |
| ed_attach(sc, unit, flags) | ed_attach(device_t dev) |
| struct ed_softc *sc; | |
| int unit; | |
| int flags; | |
| { | { |
| struct ed_softc *sc = device_get_softc(dev); | |
| struct ifnet *ifp = &sc->arpcom.ac_if; | struct ifnet *ifp = &sc->arpcom.ac_if; |
| callout_handle_init(&sc->tick_ch); | callout_handle_init(&sc->tick_ch); |
| Line 1711 ed_attach(sc, unit, flags) | Line 1722 ed_attach(sc, unit, flags) |
| * Initialize ifnet structure | * Initialize ifnet structure |
| */ | */ |
| ifp->if_softc = sc; | ifp->if_softc = sc; |
| if_initname(ifp, "ed", unit); | if_initname(ifp, device_get_name(dev), device_get_unit(dev)); |
| ifp->if_output = ether_output; | ifp->if_output = ether_output; |
| ifp->if_mtu = ETHERMTU; | |
| ifp->if_start = ed_start; | ifp->if_start = ed_start; |
| ifp->if_ioctl = ed_ioctl; | ifp->if_ioctl = ed_ioctl; |
| ifp->if_watchdog = ed_watchdog; | ifp->if_watchdog = ed_watchdog; |
| Line 1720 ed_attach(sc, unit, flags) | Line 1732 ed_attach(sc, unit, flags) |
| ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; | ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; |
| ifp->if_linkmib = &sc->mibdata; | ifp->if_linkmib = &sc->mibdata; |
| ifp->if_linkmiblen = sizeof sc->mibdata; | ifp->if_linkmiblen = sizeof sc->mibdata; |
| ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; | |
| /* | /* |
| * XXX - should do a better job. | * XXX - should do a better job. |
| */ | */ |
| Line 1738 ed_attach(sc, unit, flags) | Line 1751 ed_attach(sc, unit, flags) |
| * tranceiver for AUI operation), based on compile-time | * tranceiver for AUI operation), based on compile-time |
| * config option. | * config option. |
| */ | */ |
| if (flags & ED_FLAGS_DISABLE_TRANCEIVER) | if (device_get_flags(dev) & ED_FLAGS_DISABLE_TRANCEIVER) |
| ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | | ifp->if_flags |= IFF_ALTPHYS; |
| IFF_MULTICAST | IFF_ALTPHYS); | |
| else | |
| ifp->if_flags = (IFF_BROADCAST | IFF_SIMPLEX | | |
| IFF_MULTICAST); | |
| /* | /* |
| * Attach the interface | * Attach the interface |
| Line 1755 ed_attach(sc, unit, flags) | Line 1764 ed_attach(sc, unit, flags) |
| /* | /* |
| * Print additional info when attached | * Print additional info when attached |
| */ | */ |
| printf("%s: address %6D, ", ifp->if_xname, | if_printf(ifp, "address %6D, ", sc->arpcom.ac_enaddr, ":"); |
| sc->arpcom.ac_enaddr, ":"); | |
| if (sc->type_str && (*sc->type_str != 0)) | if (sc->type_str && (*sc->type_str != 0)) |
| printf("type %s ", sc->type_str); | printf("type %s ", sc->type_str); |
| Line 1809 ed_stop(sc) | Line 1817 ed_stop(sc) |
| { | { |
| int n = 5000; | int n = 5000; |
| #ifndef ED_NO_MIIBUS | |
| untimeout(ed_tick, sc, sc->tick_ch); | untimeout(ed_tick, sc, sc->tick_ch); |
| callout_handle_init(&sc->tick_ch); | callout_handle_init(&sc->tick_ch); |
| #endif | |
| if (sc->gone) | if (sc->gone) |
| return; | return; |
| /* | /* |
| Line 1845 ed_watchdog(ifp) | Line 1855 ed_watchdog(ifp) |
| ed_reset(ifp); | ed_reset(ifp); |
| } | } |
| #ifndef ED_NO_MIIBUS | |
| static void | static void |
| ed_tick(arg) | ed_tick(arg) |
| void *arg; | void *arg; |
| Line 1865 ed_tick(arg) | Line 1876 ed_tick(arg) |
| sc->tick_ch = timeout(ed_tick, sc, hz); | sc->tick_ch = timeout(ed_tick, sc, hz); |
| splx(s); | splx(s); |
| } | } |
| #endif | |
| /* | /* |
| * Initialize device. | * Initialize device. |
| Line 2007 ed_init(xsc) | Line 2019 ed_init(xsc) |
| } | } |
| } | } |
| #ifndef ED_NO_MIIBUS | |
| if (sc->miibus != NULL) { | if (sc->miibus != NULL) { |
| struct mii_data *mii; | struct mii_data *mii; |
| mii = device_get_softc(sc->miibus); | mii = device_get_softc(sc->miibus); |
| mii_mediachg(mii); | mii_mediachg(mii); |
| } | } |
| #endif | |
| /* | /* |
| * Set 'running' flag, and clear output active flag. | * Set 'running' flag, and clear output active flag. |
| */ | */ |
| Line 2023 ed_init(xsc) | Line 2037 ed_init(xsc) |
| */ | */ |
| ed_start(ifp); | ed_start(ifp); |
| #ifndef ED_NO_MIIBUS | |
| untimeout(ed_tick, sc, sc->tick_ch); | untimeout(ed_tick, sc, sc->tick_ch); |
| sc->tick_ch = timeout(ed_tick, sc, hz); | sc->tick_ch = timeout(ed_tick, sc, hz); |
| #endif | |
| (void) splx(s); | (void) splx(s); |
| } | } |
| Line 2203 outloop: | Line 2219 outloop: |
| } | } |
| } else { | } else { |
| len = ed_pio_write_mbufs(sc, m, (int)buffer); | len = ed_pio_write_mbufs(sc, m, (int)buffer); |
| if (len == 0) | if (len == 0) { |
| m_freem(m0); | |
| goto outloop; | goto outloop; |
| } | |
| } | } |
| sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN)); | sc->txb_len[sc->txb_new] = max(len, (ETHER_MIN_LEN-ETHER_CRC_LEN)); |
| Line 2381 edintr(arg) | Line 2399 edintr(arg) |
| struct ed_softc *sc = (struct ed_softc*) arg; | struct ed_softc *sc = (struct ed_softc*) arg; |
| struct ifnet *ifp = (struct ifnet *)sc; | struct ifnet *ifp = (struct ifnet *)sc; |
| u_char isr; | u_char isr; |
| int count; | |
| if (sc->gone) | if (sc->gone) |
| return; | return; |
| Line 2390 edintr(arg) | Line 2409 edintr(arg) |
| ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA); | ed_nic_outb(sc, ED_P0_CR, sc->cr_proto | ED_CR_STA); |
| /* | /* |
| * loop until there are no more new interrupts | * loop until there are no more new interrupts. When the card |
| * goes away, the hardware will read back 0xff. Looking at | |
| * the interrupts, it would appear that 0xff is impossible, | |
| * or at least extremely unlikely. | |
| */ | */ |
| while ((isr = ed_nic_inb(sc, ED_P0_ISR)) != 0) { | while ((isr = ed_nic_inb(sc, ED_P0_ISR)) != 0 && isr != 0xff) { |
| /* | /* |
| * reset all the bits that we are 'acknowledging' by writing a | * reset all the bits that we are 'acknowledging' by writing a |
| Line 2401 edintr(arg) | Line 2423 edintr(arg) |
| */ | */ |
| ed_nic_outb(sc, ED_P0_ISR, isr); | ed_nic_outb(sc, ED_P0_ISR, isr); |
| /* XXX workaround for AX88190 */ | /* |
| * XXX workaround for AX88190 | |
| * We limit this to 5000 iterations. At 1us per inb/outb, | |
| * this translates to about 15ms, which should be plenty | |
| * of time, and also gives protection in the card eject | |
| * case. | |
| */ | |
| if (sc->chip_type == ED_CHIP_TYPE_AX88190) { | if (sc->chip_type == ED_CHIP_TYPE_AX88190) { |
| while (ed_nic_inb(sc, ED_P0_ISR) & isr) { | count = 5000; /* 15ms */ |
| ed_nic_outb(sc, ED_P0_ISR,0); | while (count-- && (ed_nic_inb(sc, ED_P0_ISR) & isr)) { |
| ed_nic_outb(sc, ED_P0_ISR,isr); | ed_nic_outb(sc, ED_P0_ISR,0); |
| } | ed_nic_outb(sc, ED_P0_ISR,isr); |
| } | |
| if (count == 0) | |
| break; | |
| } | } |
| /* | /* |
| Line 2554 edintr(arg) | Line 2585 edintr(arg) |
| sc->mibdata.dot3StatsInternalMacReceiveErrors++; | sc->mibdata.dot3StatsInternalMacReceiveErrors++; |
| ifp->if_ierrors++; | ifp->if_ierrors++; |
| #ifdef ED_DEBUG | #ifdef ED_DEBUG |
| printf("%s: receive error %x\n", ifp->if_xname, | if_printf("receive error %x\n", |
| ed_nic_inb(sc, ED_P0_RSR)); | ed_nic_inb(sc, ED_P0_RSR)); |
| #endif | #endif |
| } | } |
| Line 2636 ed_ioctl(ifp, command, data) | Line 2667 ed_ioctl(ifp, command, data) |
| caddr_t data; | caddr_t data; |
| { | { |
| struct ed_softc *sc = ifp->if_softc; | struct ed_softc *sc = ifp->if_softc; |
| #ifndef ED_NO_MIIBUS | |
| struct ifreq *ifr = (struct ifreq *)data; | struct ifreq *ifr = (struct ifreq *)data; |
| struct mii_data *mii; | struct mii_data *mii; |
| #endif | |
| int s, error = 0; | int s, error = 0; |
| if (sc == NULL || sc->gone) { | if (sc == NULL || sc->gone) { |
| Line 2700 ed_ioctl(ifp, command, data) | Line 2733 ed_ioctl(ifp, command, data) |
| error = 0; | error = 0; |
| break; | break; |
| #ifndef ED_NO_MIIBUS | |
| case SIOCGIFMEDIA: | case SIOCGIFMEDIA: |
| case SIOCSIFMEDIA: | case SIOCSIFMEDIA: |
| if (sc->miibus == NULL) { | if (sc->miibus == NULL) { |
| Line 2709 ed_ioctl(ifp, command, data) | Line 2743 ed_ioctl(ifp, command, data) |
| mii = device_get_softc(sc->miibus); | mii = device_get_softc(sc->miibus); |
| error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); | error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, command); |
| break; | break; |
| #endif | |
| default: | default: |
| error = EINVAL; | error = EINVAL; |
| Line 2763 ed_get_packet(sc, buf, len) | Line 2798 ed_get_packet(sc, buf, len) |
| char *buf; | char *buf; |
| u_short len; | u_short len; |
| { | { |
| struct ifnet *ifp = &sc->arpcom.ac_if; | |
| struct ether_header *eh; | struct ether_header *eh; |
| struct mbuf *m; | struct mbuf *m; |
| Line 2770 ed_get_packet(sc, buf, len) | Line 2806 ed_get_packet(sc, buf, len) |
| MGETHDR(m, M_DONTWAIT, MT_DATA); | MGETHDR(m, M_DONTWAIT, MT_DATA); |
| if (m == NULL) | if (m == NULL) |
| return; | return; |
| m->m_pkthdr.rcvif = &sc->arpcom.ac_if; | m->m_pkthdr.rcvif = ifp; |
| m->m_pkthdr.len = m->m_len = len; | m->m_pkthdr.len = m->m_len = len; |
| /* | /* |
| Line 2801 ed_get_packet(sc, buf, len) | Line 2837 ed_get_packet(sc, buf, len) |
| * Don't read in the entire packet if we know we're going to drop it | * Don't read in the entire packet if we know we're going to drop it |
| * and no bpf is active. | * and no bpf is active. |
| */ | */ |
| if (!sc->arpcom.ac_if.if_bpf && BDG_ACTIVE( (&sc->arpcom.ac_if) ) ) { | if (!ifp->if_bpf && BDG_ACTIVE( (ifp) ) ) { |
| struct ifnet *bif; | struct ifnet *bif; |
| ed_ring_copy(sc, buf, (char *)eh, ETHER_HDR_LEN); | ed_ring_copy(sc, buf, (char *)eh, ETHER_HDR_LEN); |
| bif = bridge_in_ptr(&sc->arpcom.ac_if, eh) ; | bif = bridge_in_ptr(ifp, eh) ; |
| if (bif == BDG_DROP) { | if (bif == BDG_DROP) { |
| m_freem(m); | m_freem(m); |
| return; | return; |
| Line 2825 ed_get_packet(sc, buf, len) | Line 2861 ed_get_packet(sc, buf, len) |
| m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); | m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header); |
| m->m_data += sizeof(struct ether_header); | m->m_data += sizeof(struct ether_header); |
| ether_input(&sc->arpcom.ac_if, eh, m); | ether_input(ifp, eh, m); |
| } | } |
| /* | /* |
| Line 3157 ed_hpp_readmem(sc, src, dst, amount) | Line 3193 ed_hpp_readmem(sc, src, dst, amount) |
| * Only used in the probe routine to test the memory. 'len' must | * Only used in the probe routine to test the memory. 'len' must |
| * be even. | * be even. |
| */ | */ |
| void | static void |
| ed_hpp_writemem(sc, src, dst, len) | ed_hpp_writemem(sc, src, dst, len) |
| struct ed_softc *sc; | struct ed_softc *sc; |
| unsigned char *src; | unsigned char *src; |
| Line 3245 ed_hpp_write_mbufs(struct ed_softc *sc, | Line 3281 ed_hpp_write_mbufs(struct ed_softc *sc, |
| /* finish the last word of the previous mbuf */ | /* finish the last word of the previous mbuf */ |
| if (wantbyte) { | if (wantbyte) { |
| savebyte[1] = *data; | savebyte[1] = *data; |
| *d = *((ushort *) savebyte); | *d = *((u_short *) savebyte); |
| data++; len--; wantbyte = 0; | data++; len--; wantbyte = 0; |
| } | } |
| /* output contiguous words */ | /* output contiguous words */ |
| Line 3326 ed_hpp_write_mbufs(struct ed_softc *sc, | Line 3362 ed_hpp_write_mbufs(struct ed_softc *sc, |
| return (total_len); | return (total_len); |
| } | } |
| #ifndef ED_NO_MIIBUS | |
| /* | /* |
| * MII bus support routines. | * MII bus support routines. |
| */ | */ |
| Line 3343 ed_miibus_readreg(dev, phy, reg) | Line 3380 ed_miibus_readreg(dev, phy, reg) |
| splx(s); | splx(s); |
| return (0); | return (0); |
| } | } |
| (*sc->mii_writebits)(sc, 0xffffffff, 32); | (*sc->mii_writebits)(sc, 0xffffffff, 32); |
| (*sc->mii_writebits)(sc, ED_MII_STARTDELIM, ED_MII_STARTDELIM_BITS); | (*sc->mii_writebits)(sc, ED_MII_STARTDELIM, ED_MII_STARTDELIM_BITS); |
| (*sc->mii_writebits)(sc, ED_MII_READOP, ED_MII_OP_BITS); | (*sc->mii_writebits)(sc, ED_MII_READOP, ED_MII_OP_BITS); |
| Line 3429 ed_child_detached(dev, child) | Line 3466 ed_child_detached(dev, child) |
| if (child == sc->miibus) | if (child == sc->miibus) |
| sc->miibus = NULL; | sc->miibus = NULL; |
| } | } |
| #endif | |
| static void | static void |
| ed_setrcr(sc) | ed_setrcr(sc) |
| Line 3510 ed_setrcr(sc) | Line 3548 ed_setrcr(sc) |
| /* | /* |
| * Compute crc for ethernet address | * Compute crc for ethernet address |
| */ | */ |
| static u_int32_t | static uint32_t |
| ds_crc(ep) | ds_mchash(addr) |
| u_char *ep; | const uint8_t *addr; |
| { | { |
| #define POLYNOMIAL 0x04c11db6 | #define ED_POLYNOMIAL 0x04c11db6 |
| u_int32_t crc = 0xffffffff; | register uint32_t crc = 0xffffffff; |
| int carry, i, j; | register int carry, idx, bit; |
| u_char b; | register uint8_t data; |
| for (i = 6; --i >= 0;) { | for (idx = 6; --idx >= 0;) { |
| b = *ep++; | for (data = *addr++, bit = 8; --bit >= 0; data >>=1 ) { |
| for (j = 8; --j >= 0;) { | carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); |
| carry = ((crc & 0x80000000) ? 1 : 0) ^ (b & 0x01); | |
| crc <<= 1; | crc <<= 1; |
| b >>= 1; | |
| if (carry) | if (carry) |
| crc = (crc ^ POLYNOMIAL) | carry; | crc = (crc ^ ED_POLYNOMIAL) | carry; |
| } | } |
| } | } |
| return crc; | return crc; |
| Line 3553 ds_getmcaf(sc, mcaf) | Line 3589 ds_getmcaf(sc, mcaf) |
| ifma = ifma->ifma_link.le_next) { | ifma = ifma->ifma_link.le_next) { |
| if (ifma->ifma_addr->sa_family != AF_LINK) | if (ifma->ifma_addr->sa_family != AF_LINK) |
| continue; | continue; |
| index = ds_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) | index = ds_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)) |
| >> 26; | >> 26; |
| af[index >> 3] |= 1 << (index & 7); | af[index >> 3] |= 1 << (index & 7); |
| } | } |