summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/dp8390.c20
-rw-r--r--sys/dev/ic/rtl81x9.c38
2 files changed, 10 insertions, 48 deletions
diff --git a/sys/dev/ic/dp8390.c b/sys/dev/ic/dp8390.c
index 37a461ef099..8f8ea1572ab 100644
--- a/sys/dev/ic/dp8390.c
+++ b/sys/dev/ic/dp8390.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dp8390.c,v 1.25 2004/05/12 06:35:10 tedu Exp $ */
+/* $OpenBSD: dp8390.c,v 1.26 2004/06/06 17:56:36 mcbride Exp $ */
/* $NetBSD: dp8390.c,v 1.13 1998/07/05 06:49:11 jonathan Exp $ */
/*
@@ -972,9 +972,8 @@ dp8390_getmcaf(ec, af)
{
struct ifnet *ifp = &ec->ac_if;
struct ether_multi *enm;
- u_int8_t *cp, c;
u_int32_t crc;
- int i, len;
+ int i;
struct ether_multistep step;
/*
@@ -1010,21 +1009,8 @@ dp8390_getmcaf(ec, af)
af[i] = 0xff;
return;
}
- cp = enm->enm_addrlo;
- crc = 0xffffffff;
- for (len = sizeof(enm->enm_addrlo); --len >= 0;) {
- c = *cp++;
- for (i = 8; --i >= 0;) {
- if (((crc & 0x80000000) ? 1 : 0) ^ (c & 0x01)) {
- crc <<= 1;
- crc ^= 0x04c11db6 | 1;
- } else
- crc <<= 1;
- c >>= 1;
- }
- }
/* Just want the 6 most significant bits. */
- crc >>= 26;
+ crc = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26;
/* Turn on the corresponding bit in the filter. */
af[crc >> 3] |= 1 << (crc & 0x7);
diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c
index dcd99aeca5c..94705284561 100644
--- a/sys/dev/ic/rtl81x9.c
+++ b/sys/dev/ic/rtl81x9.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtl81x9.c,v 1.25 2004/05/19 11:36:59 brad Exp $ */
+/* $OpenBSD: rtl81x9.c,v 1.26 2004/06/06 17:56:36 mcbride Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -160,7 +160,6 @@ int rl_miibus_readreg(struct device *, int, int);
void rl_miibus_writereg(struct device *, int, int, int);
void rl_miibus_statchg(struct device *);
-u_int8_t rl_calchash(caddr_t);
void rl_setmulti(struct rl_softc *);
void rl_reset(struct rl_softc *);
int rl_list_tx_init(struct rl_softc *);
@@ -461,34 +460,6 @@ int rl_mii_writereg(sc, frame)
}
/*
- * Calculate CRC of a multicast group address, return the upper 6 bits.
- */
-u_int8_t rl_calchash(addr)
- caddr_t addr;
-{
- u_int32_t crc, carry;
- int i, j;
- u_int8_t c;
-
- /* 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);
- crc <<= 1;
- c >>= 1;
- if (carry)
- crc = (crc ^ 0x04c11db6) | carry;
- }
- }
-
- /* return the filter bit position */
- return(crc >> 26);
-}
-
-/*
* Program the 64-bit multicast hash filter.
*/
void rl_setmulti(sc)
@@ -507,6 +478,7 @@ void rl_setmulti(sc)
rxfilt = CSR_READ_4(sc, RL_RXCFG);
+allmulti:
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
rxfilt |= RL_RXCFG_RX_MULTI;
CSR_WRITE_4(sc, RL_RXCFG, rxfilt);
@@ -522,8 +494,12 @@ void rl_setmulti(sc)
/* now program new ones */
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
+ if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+ ifp->if_flags |= IFF_ALLMULTI;
+ goto allmulti;
+ }
mcnt++;
- h = rl_calchash(enm->enm_addrlo);
+ h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26;
if (h < 32)
hashes[0] |= (1 << h);
else