diff options
author | obrien <obrien@FreeBSD.org> | 2003-11-13 20:55:53 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2003-11-13 20:55:53 +0000 |
commit | ae5ec4308110fc11464507f63b5d9a1908a426b8 (patch) | |
tree | 9f53fad8ba546c1e709992d118c397465dd5b01f /sys/pci/if_ste.c | |
parent | a9128aec4ed6ce7c8d433530c6899775e94045d0 (diff) | |
download | FreeBSD-src-ae5ec4308110fc11464507f63b5d9a1908a426b8.zip FreeBSD-src-ae5ec4308110fc11464507f63b5d9a1908a426b8.tar.gz |
Try to create some sort of consistency in how the routings to find the
multicast hash are written. There are still two distinct algorithms used,
and there actually isn't any reason each driver should have its own copy
of this function as they could all share one copy of it (if it grew an
additional argument).
Diffstat (limited to 'sys/pci/if_ste.c')
-rw-r--r-- | sys/pci/if_ste.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/pci/if_ste.c b/sys/pci/if_ste.c index 3bf8b33..cf1e920 100644 --- a/sys/pci/if_ste.c +++ b/sys/pci/if_ste.c @@ -119,7 +119,7 @@ static void ste_miibus_statchg (device_t); static int ste_eeprom_wait (struct ste_softc *); static int ste_read_eeprom (struct ste_softc *, caddr_t, int, int, int); static void ste_wait (struct ste_softc *); -static u_int8_t ste_calchash (caddr_t); +static u_int32_t ste_mchash (caddr_t); static void ste_setmulti (struct ste_softc *); static int ste_init_rx_list (struct ste_softc *); static void ste_init_tx_list (struct ste_softc *); @@ -552,24 +552,22 @@ ste_read_eeprom(sc, dest, off, cnt, swap) return(err ? 1 : 0); } -static u_int8_t -ste_calchash(addr) - caddr_t addr; +static u_int32_t +ste_mchash(addr) + caddr_t addr; { - u_int32_t crc, carry; - int i, j; - u_int8_t c; + u_int32_t crc, carry; + int idx, bit; + u_int8_t data; /* Compute CRC for the address value. */ crc = 0xFFFFFFFF; /* initial value */ - for (i = 0; i < 6; i++) { - c = *(addr + i); - for (j = 0; j < 8; j++) { - carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01); + for (idx = 0; idx < 6; idx++) { + for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) { + carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01); crc <<= 1; - c >>= 1; if (carry) crc = (crc ^ 0x04c11db6) | carry; } @@ -605,7 +603,7 @@ ste_setmulti(sc) TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) continue; - h = ste_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); + h = ste_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); if (h < 32) hashes[0] |= (1 << h); else |