summaryrefslogtreecommitdiffstats
path: root/sys/dev/fe
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/fe
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/fe')
-rw-r--r--sys/dev/fe/if_fe.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/sys/dev/fe/if_fe.c b/sys/dev/fe/if_fe.c
index 8e9c69e..23f1322 100644
--- a/sys/dev/fe/if_fe.c
+++ b/sys/dev/fe/if_fe.c
@@ -2046,26 +2046,24 @@ fe_write_mbufs (struct fe_softc *sc, struct mbuf *m)
/*
* Compute hash value for an Ethernet address
*/
-static int
-fe_hash ( u_char * ep )
+static u_int32_t
+fe_mchash (caddr_t addr)
{
-#define FE_HASH_MAGIC_NUMBER 0xEDB88320L
-
- u_long hash = 0xFFFFFFFFL;
- int i, j;
- u_char b;
- u_long m;
-
- for ( i = ETHER_ADDR_LEN; --i >= 0; ) {
- b = *ep++;
- for ( j = 8; --j >= 0; ) {
- m = hash;
- hash >>= 1;
- if ( ( m ^ b ) & 1 ) hash ^= FE_HASH_MAGIC_NUMBER;
- b >>= 1;
+#define FE_POLY 0xEDB88320L
+
+ u_long carry, crc = 0xFFFFFFFFL;
+ int idx, bit;
+ u_int8_t data;
+
+ for ( idx = ETHER_ADDR_LEN; --idx >= 0; ) {
+ for (data = *addr++, bit = 8; --bit >= 0; data >>= 1) {
+ carry = crc;
+ crc >>= 1;
+ if ((carry ^ data) & 1)
+ crc ^= FE_POLY;
}
}
- return ( ( int )( hash >> 26 ) );
+ return (crc >> 26);
}
/*
@@ -2083,7 +2081,7 @@ fe_mcaf ( struct fe_softc *sc )
TAILQ_FOREACH(ifma, &sc->arpcom.ac_if.if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- index = fe_hash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ index = fe_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
#ifdef FE_DEBUG
printf("%s: hash(%6D) == %d\n",
sc->sc_xname, enm->enm_addrlo , ":", index);
OpenPOWER on IntegriCloud