summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/if_ste.c37
-rw-r--r--sys/dev/pci/if_stge.c32
-rw-r--r--sys/dev/pci/if_vr.c39
-rw-r--r--sys/dev/pci/if_wb.c40
4 files changed, 26 insertions, 122 deletions
diff --git a/sys/dev/pci/if_ste.c b/sys/dev/pci/if_ste.c
index 4c10b2cdada..4b866fe8b84 100644
--- a/sys/dev/pci/if_ste.c
+++ b/sys/dev/pci/if_ste.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ste.c,v 1.21 2004/04/09 21:52:17 henning Exp $ */
+/* $OpenBSD: if_ste.c,v 1.22 2004/06/06 17:56:36 mcbride Exp $ */
/*
* Copyright (c) 1997, 1998, 1999
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
@@ -115,7 +115,6 @@ int ste_eeprom_wait(struct ste_softc *);
int ste_read_eeprom(struct ste_softc *, caddr_t, int,
int, int);
void ste_wait(struct ste_softc *);
-u_int8_t ste_calchash(caddr_t);
void ste_setmulti(struct ste_softc *);
int ste_init_rx_list(struct ste_softc *);
void ste_init_tx_list(struct ste_softc *);
@@ -491,32 +490,6 @@ int ste_read_eeprom(sc, dest, off, cnt, swap)
return(err ? 1 : 0);
}
-u_int8_t ste_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 & 0x0000003F);
-}
-
void ste_setmulti(sc)
struct ste_softc *sc;
{
@@ -528,6 +501,7 @@ void ste_setmulti(sc)
u_int32_t hashes[2] = { 0, 0 };
ifp = &sc->arpcom.ac_if;
+allmulti:
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
STE_SETBIT1(sc, STE_RX_MODE, STE_RXMODE_ALLMULTI);
STE_CLRBIT1(sc, STE_RX_MODE, STE_RXMODE_MULTIHASH);
@@ -541,7 +515,12 @@ void ste_setmulti(sc)
/* now program new ones */
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
- h = ste_calchash(enm->enm_addrlo);
+ if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+ ifp->if_flags |= IFF_ALLMULTI;
+ goto allmulti;
+ }
+ h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) &
+ 0x0000003F;
if (h < 32)
hashes[0] |= (1 << h);
else
diff --git a/sys/dev/pci/if_stge.c b/sys/dev/pci/if_stge.c
index bc45e7655ce..0313839531a 100644
--- a/sys/dev/pci/if_stge.c
+++ b/sys/dev/pci/if_stge.c
@@ -1860,33 +1860,6 @@ stge_add_rxbuf(struct stge_softc *sc, int idx)
return (0);
}
-u_int8_t stge_calchash(caddr_t);
-
-u_int8_t stge_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 & 0x0000003F);
-}
-
/*
* stge_set_filter:
*
@@ -1923,7 +1896,10 @@ stge_set_filter(struct stge_softc *sc)
goto done;
while (enm != NULL) {
- h = stge_calchash(enm->enm_addrlo);
+ if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN))
+ goto allmulti;
+ h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) &
+ 0x0000003F;
if (h < 32)
mchash[0] |= (1 << h);
else
diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c
index 0148f7ae8f7..1981f62d666 100644
--- a/sys/dev/pci/if_vr.c
+++ b/sys/dev/pci/if_vr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vr.c,v 1.42 2004/04/14 04:48:56 deraadt Exp $ */
+/* $OpenBSD: if_vr.c,v 1.43 2004/06/06 17:56:36 mcbride Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -136,7 +136,6 @@ void vr_miibus_writereg(struct device *, int, int, int);
void vr_miibus_statchg(struct device *);
void vr_setcfg(struct vr_softc *, int);
-u_int8_t vr_calchash(u_int8_t *);
void vr_setmulti(struct vr_softc *);
void vr_reset(struct vr_softc *);
int vr_list_rx_init(struct vr_softc *);
@@ -491,35 +490,6 @@ vr_miibus_statchg(dev)
}
/*
- * Calculate CRC of a multicast group address, return the lower 6 bits.
- */
-u_int8_t
-vr_calchash(addr)
- u_int8_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) & 0x0000003F);
-}
-
-/*
* Program the 64-bit multicast hash filter.
*/
void
@@ -539,6 +509,7 @@ vr_setmulti(sc)
rxfilt = CSR_READ_1(sc, VR_RXCFG);
+allmulti:
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
rxfilt |= VR_RXCFG_RX_MULTI;
CSR_WRITE_1(sc, VR_RXCFG, rxfilt);
@@ -554,7 +525,11 @@ vr_setmulti(sc)
/* now program new ones */
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
- h = vr_calchash(enm->enm_addrlo);
+ if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+ ifp->if_flags |= IFF_ALLMULTI;
+ goto allmulti;
+ }
+ h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26;
if (h < 32)
hashes[0] |= (1 << h);
else
diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c
index d74a612662b..de6d6ec090e 100644
--- a/sys/dev/pci/if_wb.c
+++ b/sys/dev/pci/if_wb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wb.c,v 1.22 2003/08/19 14:01:35 mpech Exp $ */
+/* $OpenBSD: if_wb.c,v 1.23 2004/06/06 17:56:37 mcbride Exp $ */
/*
* Copyright (c) 1997, 1998
@@ -521,37 +521,6 @@ wb_miibus_statchg(dev)
wb_setcfg(sc, sc->sc_mii.mii_media_active);
}
-u_int8_t wb_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
- * Note: I arrived at the following nonsense
- * through experimentation. It's not the usual way to
- * generate the bit position but it's the only thing
- * I could come up with that works.
- */
- return(~(crc >> 26) & 0x0000003F);
-}
-
/*
* Program the 64-bit multicast hash filter.
*/
@@ -571,6 +540,7 @@ void wb_setmulti(sc)
rxfilt = CSR_READ_4(sc, WB_NETCFG);
+allmulti:
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
rxfilt |= WB_NETCFG_RX_MULTI;
CSR_WRITE_4(sc, WB_NETCFG, rxfilt);
@@ -586,7 +556,11 @@ void wb_setmulti(sc)
/* now program new ones */
ETHER_FIRST_MULTI(step, ac, enm);
while (enm != NULL) {
- h = wb_calchash(enm->enm_addrlo);
+ if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
+ ifp->if_flags |= IFF_ALLMULTI;
+ goto allmulti;
+ }
+ h = ~(ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26);
if (h < 32)
hashes[0] |= (1 << h);
else