Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 28 Feb 2010 16:11:13 +0000 (UTC)
From:      Bernd Walter <ticso@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r204462 - head/sys/arm/at91
Message-ID:  <201002281611.o1SGBDPv026847@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002281611.o1SGBDPv026847>