summaryrefslogtreecommitdiffstats
path: root/sys/dev/fe/if_fe.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/fe/if_fe.c')
-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