summaryrefslogtreecommitdiffstats
path: root/sys/pci
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/pci
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/pci')
-rw-r--r--sys/pci/if_dc.c43
-rw-r--r--sys/pci/if_pcn.c12
-rw-r--r--sys/pci/if_rl.c24
-rw-r--r--sys/pci/if_sf.c22
-rw-r--r--sys/pci/if_sis.c21
-rw-r--r--sys/pci/if_sk.c14
-rw-r--r--sys/pci/if_ste.c24
-rw-r--r--sys/pci/if_tl.c12
-rw-r--r--sys/pci/if_vr.c23
-rw-r--r--sys/pci/if_wb.c23
-rw-r--r--sys/pci/if_xl.c23
11 files changed, 119 insertions, 122 deletions
diff --git a/sys/pci/if_dc.c b/sys/pci/if_dc.c
index ca59ef1..91b4261 100644
--- a/sys/pci/if_dc.c
+++ b/sys/pci/if_dc.c
@@ -264,8 +264,8 @@ static void dc_miibus_statchg (device_t);
static void dc_miibus_mediainit (device_t);
static void dc_setcfg (struct dc_softc *, int);
-static u_int32_t dc_crc_le (struct dc_softc *, const uint8_t *);
-static u_int32_t dc_crc_be (const uint8_t *);
+static u_int32_t dc_mchash_le (struct dc_softc *, caddr_t);
+static u_int32_t dc_mchash_be (caddr_t);
static void dc_setfilt_21143 (struct dc_softc *);
static void dc_setfilt_asix (struct dc_softc *);
static void dc_setfilt_admtek (struct dc_softc *);
@@ -1021,9 +1021,11 @@ dc_miibus_mediainit(device_t dev)
#define DC_BITS_64 6
static u_int32_t
-dc_crc_le(struct dc_softc *sc, const uint8_t *addr)
+dc_mchash_le(struct dc_softc *sc, caddr_t addr)
{
- uint32_t idx, bit, data, crc;
+ u_int32_t crc;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
@@ -1061,21 +1063,20 @@ dc_crc_le(struct dc_softc *sc, const uint8_t *addr)
* Calculate CRC of a multicast group address, return the lower 6 bits.
*/
static u_int32_t
-dc_crc_be(const uint8_t *addr)
+dc_mchash_be(caddr_t addr)
{
- uint32_t crc, carry;
- int i, j;
- uint8_t c;
+ u_int32_t crc, carry;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
+ data >>= 1;
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -1133,13 +1134,13 @@ dc_setfilt_21143(struct dc_softc *sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = dc_crc_le(sc,
+ h = dc_mchash_le(sc,
LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
sp[h >> 4] |= htole32(1 << (h & 0xF));
}
if (ifp->if_flags & IFF_BROADCAST) {
- h = dc_crc_le(sc, ifp->if_broadcastaddr);
+ h = dc_mchash_le(sc, ifp->if_broadcastaddr);
sp[h >> 4] |= htole32(1 << (h & 0xF));
}
@@ -1203,9 +1204,11 @@ dc_setfilt_admtek(struct dc_softc *sc)
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
if (DC_IS_CENTAUR(sc))
- h = dc_crc_le(sc, LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = dc_mchash_le(sc,
+ LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
else
- h = dc_crc_be(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = dc_mchash_be(
+ LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
else
@@ -1271,7 +1274,7 @@ dc_setfilt_asix(struct dc_softc *sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = dc_crc_be(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = dc_mchash_be(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
else
@@ -1323,13 +1326,13 @@ dc_setfilt_xircom(struct dc_softc *sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = dc_crc_le(sc,
+ h = dc_mchash_le(sc,
LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
sp[h >> 4] |= htole32(1 << (h & 0xF));
}
if (ifp->if_flags & IFF_BROADCAST) {
- h = dc_crc_le(sc, ifp->if_broadcastaddr);
+ h = dc_mchash_le(sc, ifp->if_broadcastaddr);
sp[h >> 4] |= htole32(1 << (h & 0xF));
}
diff --git a/sys/pci/if_pcn.c b/sys/pci/if_pcn.c
index 57dd4a6..c5bd726 100644
--- a/sys/pci/if_pcn.c
+++ b/sys/pci/if_pcn.c
@@ -136,7 +136,7 @@ static void pcn_miibus_statchg (device_t);
static void pcn_setfilt (struct ifnet *);
static void pcn_setmulti (struct pcn_softc *);
-static u_int32_t pcn_crc (caddr_t);
+static u_int32_t pcn_mchash (caddr_t);
static void pcn_reset (struct pcn_softc *);
static int pcn_list_rx_init (struct pcn_softc *);
static int pcn_list_tx_init (struct pcn_softc *);
@@ -309,10 +309,12 @@ pcn_miibus_statchg(dev)
#define DC_POLY 0xEDB88320
static u_int32_t
-pcn_crc(addr)
- caddr_t addr;
+pcn_mchash(addr)
+ caddr_t addr;
{
- u_int32_t idx, bit, data, crc;
+ u_int32_t crc;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
@@ -353,7 +355,7 @@ pcn_setmulti(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = pcn_crc(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = pcn_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
hashes[h >> 4] |= 1 << (h & 0xF);
}
diff --git a/sys/pci/if_rl.c b/sys/pci/if_rl.c
index e315a0c..f7b6db4 100644
--- a/sys/pci/if_rl.c
+++ b/sys/pci/if_rl.c
@@ -207,7 +207,7 @@ static int rl_miibus_readreg (device_t, int, int);
static int rl_miibus_writereg (device_t, int, int, int);
static void rl_miibus_statchg (device_t);
-static u_int8_t rl_calchash (caddr_t);
+static u_int32_t rl_mchash (caddr_t);
static void rl_setmulti (struct rl_softc *);
static void rl_reset (struct rl_softc *);
static int rl_list_tx_init (struct rl_softc *);
@@ -735,23 +735,21 @@ rl_miibus_statchg(dev)
/*
* Calculate CRC of a multicast group address, return the upper 6 bits.
*/
-static u_int8_t
-rl_calchash(addr)
- caddr_t addr;
+static u_int32_t
+rl_mchash(addr)
+ caddr_t addr;
{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
+ u_int32_t crc, carry;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>=1 ) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -795,7 +793,7 @@ rl_setmulti(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = rl_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = rl_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
else
diff --git a/sys/pci/if_sf.c b/sys/pci/if_sf.c
index 6642809..ede1a49 100644
--- a/sys/pci/if_sf.c
+++ b/sys/pci/if_sf.c
@@ -160,7 +160,7 @@ static int sf_setvlan (struct sf_softc *, int, u_int32_t);
#endif
static u_int8_t sf_read_eeprom (struct sf_softc *, int);
-static u_int32_t sf_calchash (caddr_t);
+static u_int32_t sf_mchash (caddr_t);
static int sf_miibus_readreg (device_t, int, int);
static int sf_miibus_writereg (device_t, int, int, int);
@@ -260,22 +260,20 @@ csr_write_4(sc, reg, val)
}
static u_int32_t
-sf_calchash(addr)
- caddr_t addr;
+sf_mchash(addr)
+ caddr_t addr;
{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
+ u_int32_t crc, carry;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -332,7 +330,7 @@ sf_sethash(sc, mac, prio)
if (mac == NULL)
return(EINVAL);
- h = sf_calchash(mac);
+ h = sf_mchash(mac);
if (prio) {
SF_SETBIT(sc, SF_RXFILT_HASH_BASE + SF_RXFILT_HASH_PRIOOFF +
diff --git a/sys/pci/if_sis.c b/sys/pci/if_sis.c
index 896faf0..99a8e42 100644
--- a/sys/pci/if_sis.c
+++ b/sys/pci/if_sis.c
@@ -156,7 +156,7 @@ static void sis_miibus_statchg (device_t);
static void sis_setmulti_sis (struct sis_softc *);
static void sis_setmulti_ns (struct sis_softc *);
-static u_int32_t sis_crc (struct sis_softc *, caddr_t);
+static u_int32_t sis_mchash (struct sis_softc *, caddr_t);
static void sis_reset (struct sis_softc *);
static int sis_list_rx_init (struct sis_softc *);
static int sis_list_tx_init (struct sis_softc *);
@@ -838,23 +838,21 @@ sis_miibus_statchg(dev)
}
static u_int32_t
-sis_crc(sc, addr)
+sis_mchash(sc, addr)
struct sis_softc *sc;
caddr_t addr;
{
u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -910,7 +908,8 @@ sis_setmulti_ns(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = sis_crc(sc, LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = sis_mchash(sc,
+ LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
index = h >> 3;
bit = h & 0x1F;
CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + index);
@@ -960,7 +959,7 @@ sis_setmulti_sis(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = sis_crc(sc,
+ h = sis_mchash(sc,
LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
hashes[h >> 4] |= 1 << (h & 0xf);
i++;
diff --git a/sys/pci/if_sk.c b/sys/pci/if_sk.c
index 9331328..1b0c41a 100644
--- a/sys/pci/if_sk.c
+++ b/sys/pci/if_sk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sk.c,v 1.33 2003/08/12 05:23:06 nate Exp $ */
+/* $OpenBSD: if_sk.c,v 2.33 2003/08/12 05:23:06 nate Exp $ */
/*
* Copyright (c) 1997, 1998, 1999, 2000
@@ -226,7 +226,7 @@ static int sk_marv_miibus_writereg (struct sk_if_softc *, int, int,
int);
static void sk_marv_miibus_statchg (struct sk_if_softc *);
-static u_int32_t sk_calchash (caddr_t);
+static u_int32_t sk_mchash (caddr_t);
static void sk_setfilt (struct sk_if_softc *, caddr_t, int);
static void sk_setmulti (struct sk_if_softc *);
@@ -715,10 +715,12 @@ sk_marv_miibus_statchg(sc_if)
#define SK_BITS 6
static u_int32_t
-sk_calchash(addr)
- caddr_t addr;
+sk_mchash(addr)
+ caddr_t addr;
{
- u_int32_t idx, bit, data, crc;
+ u_int32_t crc;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
@@ -798,7 +800,7 @@ sk_setmulti(sc_if)
continue;
}
- h = sk_calchash(
+ h = sk_mchash(
LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
diff --git a/sys/pci/if_ste.c b/sys/pci/if_ste.c
index 3bf8b33..cf1e920 100644
--- a/sys/pci/if_ste.c
+++ b/sys/pci/if_ste.c
@@ -119,7 +119,7 @@ static void ste_miibus_statchg (device_t);
static int ste_eeprom_wait (struct ste_softc *);
static int ste_read_eeprom (struct ste_softc *, caddr_t, int, int, int);
static void ste_wait (struct ste_softc *);
-static u_int8_t ste_calchash (caddr_t);
+static u_int32_t ste_mchash (caddr_t);
static void ste_setmulti (struct ste_softc *);
static int ste_init_rx_list (struct ste_softc *);
static void ste_init_tx_list (struct ste_softc *);
@@ -552,24 +552,22 @@ ste_read_eeprom(sc, dest, off, cnt, swap)
return(err ? 1 : 0);
}
-static u_int8_t
-ste_calchash(addr)
- caddr_t addr;
+static u_int32_t
+ste_mchash(addr)
+ caddr_t addr;
{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
+ u_int32_t crc, carry;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -605,7 +603,7 @@ ste_setmulti(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = ste_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = ste_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
else
diff --git a/sys/pci/if_tl.c b/sys/pci/if_tl.c
index 8063e77..438215c 100644
--- a/sys/pci/if_tl.c
+++ b/sys/pci/if_tl.c
@@ -300,7 +300,7 @@ static int tl_miibus_writereg (device_t, int, int, int);
static void tl_miibus_statchg (device_t);
static void tl_setmode (struct tl_softc *, int);
-static int tl_calchash (caddr_t);
+static u_int32_t tl_mchash (caddr_t);
static void tl_setmulti (struct tl_softc *);
static void tl_setfilt (struct tl_softc *, caddr_t, int);
static void tl_softreset (struct tl_softc *, int);
@@ -889,11 +889,11 @@ tl_setmode(sc, media)
* Bytes 0-2 and 3-5 are symmetrical, so are folded together. Then
* the folded 24-bit value is split into 6-bit portions and XOR'd.
*/
-static int
-tl_calchash(addr)
- caddr_t addr;
+static u_int32_t
+tl_mchash(addr)
+ caddr_t addr;
{
- int t;
+ int t;
t = (addr[0] ^ addr[3]) << 16 | (addr[1] ^ addr[4]) << 8 |
(addr[2] ^ addr[5]);
@@ -978,7 +978,7 @@ tl_setmulti(sc)
continue;
}
- h = tl_calchash(
+ h = tl_mchash(
LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
diff --git a/sys/pci/if_vr.c b/sys/pci/if_vr.c
index ffd2c3e..a65f521 100644
--- a/sys/pci/if_vr.c
+++ b/sys/pci/if_vr.c
@@ -161,7 +161,7 @@ static int vr_miibus_writereg (device_t, int, int, int);
static void vr_miibus_statchg (device_t);
static void vr_setcfg (struct vr_softc *, int);
-static u_int8_t vr_calchash (u_int8_t *);
+static u_int32_t vr_mchash (caddr_t);
static void vr_setmulti (struct vr_softc *);
static void vr_reset (struct vr_softc *);
static int vr_list_rx_init (struct vr_softc *);
@@ -565,22 +565,21 @@ vr_miibus_statchg(dev)
/*
* Calculate CRC of a multicast group address, return the lower 6 bits.
*/
-static u_int8_t vr_calchash(addr)
- u_int8_t *addr;
+static u_int32_t
+vr_mchash(addr)
+ caddr_t addr;
{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
+ u_int32_t crc, carry;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -624,7 +623,7 @@ vr_setmulti(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = vr_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = vr_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
else
diff --git a/sys/pci/if_wb.c b/sys/pci/if_wb.c
index c53e41d..d1e36e1 100644
--- a/sys/pci/if_wb.c
+++ b/sys/pci/if_wb.c
@@ -175,7 +175,7 @@ static int wb_mii_readreg (struct wb_softc *, struct wb_mii_frame *);
static int wb_mii_writereg (struct wb_softc *, struct wb_mii_frame *);
static void wb_setcfg (struct wb_softc *, u_int32_t);
-static u_int8_t wb_calchash (caddr_t);
+static u_int32_t wb_mchash (caddr_t);
static void wb_setmulti (struct wb_softc *);
static void wb_reset (struct wb_softc *);
static void wb_fixmedia (struct wb_softc *);
@@ -587,22 +587,21 @@ wb_miibus_statchg(dev)
return;
}
-static u_int8_t wb_calchash(addr)
- caddr_t addr;
+static u_int32_t
+wb_mchash(addr)
+ caddr_t addr;
{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
+ u_int32_t crc, carry;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -652,7 +651,7 @@ wb_setmulti(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = wb_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = wb_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
if (h < 32)
hashes[0] |= (1 << h);
else
diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c
index 47a85d5..ed5e3c4 100644
--- a/sys/pci/if_xl.c
+++ b/sys/pci/if_xl.c
@@ -239,7 +239,7 @@ static int xl_mii_writereg (struct xl_softc *, struct xl_mii_frame *);
static void xl_setcfg (struct xl_softc *);
static void xl_setmode (struct xl_softc *, int);
-static u_int8_t xl_calchash (caddr_t);
+static u_int32_t xl_mchash (caddr_t);
static void xl_setmulti (struct xl_softc *);
static void xl_setmulti_hash (struct xl_softc *);
static void xl_reset (struct xl_softc *);
@@ -810,22 +810,21 @@ xl_read_eeprom(sc, dest, off, cnt, swap)
* 256 bit hash table. This means we have to use all 8 bits regardless.
* On older cards, the upper 2 bits will be ignored. Grrrr....
*/
-static u_int8_t xl_calchash(addr)
- caddr_t addr;
+static u_int32_t
+xl_mchash(addr)
+ caddr_t addr;
{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
+ u_int32_t crc, carry;
+ int idx, bit;
+ u_int8_t data;
/* Compute CRC for the address value. */
crc = 0xFFFFFFFF; /* initial value */
- for (i = 0; i < 6; i++) {
- c = *(addr + i);
- for (j = 0; j < 8; j++) {
- carry = ((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01);
+ for (idx = 0; idx < 6; idx++) {
+ for (data = *addr++, bit = 0; bit < 8; bit++, data >>= 1) {
+ carry = ((crc & 0x80000000) ? 1 : 0) ^ (data & 0x01);
crc <<= 1;
- c >>= 1;
if (carry)
crc = (crc ^ 0x04c11db6) | carry;
}
@@ -906,7 +905,7 @@ xl_setmulti_hash(sc)
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
- h = xl_calchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
+ h = xl_mchash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH|XL_HASH_SET|h);
mcnt++;
}
OpenPOWER on IntegriCloud