summaryrefslogtreecommitdiffstats
path: root/sys/dev/ed
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2003-11-13 20:55:53 +0000
committerobrien <obrien@FreeBSD.org>2003-11-13 20:55:53 +0000
commitae5ec4308110fc11464507f63b5d9a1908a426b8 (patch)
tree9f53fad8ba546c1e709992d118c397465dd5b01f /sys/dev/ed
parenta9128aec4ed6ce7c8d433530c6899775e94045d0 (diff)
downloadFreeBSD-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/dev/ed')
-rw-r--r--sys/dev/ed/if_ed.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index 1ec954f..8863e9d 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -103,7 +103,7 @@ static u_short ed_pio_write_mbufs(struct ed_softc *, struct mbuf *, int);
static void ed_setrcr (struct ed_softc *);
-static u_int32_t ds_crc (u_char *ep);
+static u_int32_t ds_mchash (caddr_t addr);
/*
* Interrupt conversion table for WD/SMC ASIC/83C584
@@ -3531,22 +3531,20 @@ ed_setrcr(sc)
* Compute crc for ethernet address
*/
static u_int32_t
-ds_crc(ep)
- u_char *ep;
+ds_mchash(addr)
+ caddr_t addr;
{
-#define POLYNOMIAL 0x04c11db6
+#define ED_POLYNOMIAL 0x04c11db6
register u_int32_t crc = 0xffffffff;
- register int carry, i, j;
- register u_char b;
+ register int carry, idx, bit;
+ register u_char data;
- for (i = 6; --i >= 0;) {
- b = *ep++;
- for (j = 8; --j >= 0;) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (b & 0x01);
+ for (idx = 6; --idx >= 0;) {
+ for (data = *addr++, bit = 8; --bit >= 0; data >>=1 ) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- b >>= 1;
if (carry)
- crc = (crc ^ POLYNOMIAL) | carry;
+ crc = (crc ^ ED_POLYNOMIAL) | carry;
}
}
return crc;
@@ -3572,7 +3570,7 @@ ds_getmcaf(sc, mcaf)
TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- index = ds_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr))
+ index = ds_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr))
>> 26;
af[index >> 3] |= 1 << (index & 7);
}
OpenPOWER on IntegriCloud