Author: ticso
Date: Sun Feb 28 16:11:13 2010
New Revision: 204462
URL: http://svn.freebsd.org/changeset/base/204462

Log:
  Fix multicast hashes.
  Atmel uses a simple xor hash instead of the typical crc based one.

Modified:
  head/sys/arm/at91/if_ate.c

Modified: head/sys/arm/at91/if_ate.c
==============================================================================
--- head/sys/arm/at91/if_ate.c  Sun Feb 28 14:43:55 2010        (r204461)
+++ head/sys/arm/at91/if_ate.c  Sun Feb 28 16:11:13 2010        (r204462)
@@ -380,6 +380,20 @@ ate_load_rx_buf(void *arg, bus_dma_segme
        bus_dmamap_sync(sc->rxtag, sc->rx_map[i], BUS_DMASYNC_PREREAD);
 }
 
+static uint32_t
+ate_mac_hash(const uint8_t *buf)
+{
+       uint32_t index = 0;
+       uint8_t bit;
+       uint8_t bitshift;
+       for (int i = 0; i < 48; i++) {
+               bit = i / 6;
+               bitshift =  i - bit * 6;
+               index ^= ((buf[i >> 3] >> (i & 7)) & 1) << bitshift;
+       }
+       return (index);
+}
+
 /*
  * Compute the multicast filter for this device using the standard
  * algorithm.  I wonder why this isn't in ether somewhere as a lot
@@ -414,8 +428,9 @@ ate_setmcast(struct ate_softc *sc)
        TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
                if (ifma->ifma_addr->sa_family != AF_LINK)
                        continue;
-               index = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-                   ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
+               index = 0;
+               index = ate_mac_hash(LLADDR((struct sockaddr_dl *)
+                   ifma->ifma_addr));
                af[index >> 3] |= 1 << (index & 7);
        }
        if_maddr_runlock(ifp);
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to