diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-11-26 09:50:34 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2013-11-26 09:50:34 +0000 |
commit | 3b2e59a86d7cdbb14446277252ac4029ad50a025 (patch) | |
tree | f0ecf9018ecc9c09e51420fbaea423b178e1ad3c /sys/dev/pci | |
parent | c9ed8e3acafb6f8b5270d893558be103887617d7 (diff) |
Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.
This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.
ok naddy@, dlg@
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/if_de.c | 28 | ||||
-rw-r--r-- | sys/dev/pci/if_ixgb.c | 13 | ||||
-rw-r--r-- | sys/dev/pci/if_lge.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/if_nge.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/if_pcn.c | 17 | ||||
-rw-r--r-- | sys/dev/pci/if_tl.c | 17 | ||||
-rw-r--r-- | sys/dev/pci/if_txp.c | 21 | ||||
-rw-r--r-- | sys/dev/pci/if_wb.c | 10 | ||||
-rw-r--r-- | sys/dev/pci/if_xge.c | 9 |
9 files changed, 45 insertions, 90 deletions
diff --git a/sys/dev/pci/if_de.c b/sys/dev/pci/if_de.c index 7178281a15e..ecaa384bb2f 100644 --- a/sys/dev/pci/if_de.c +++ b/sys/dev/pci/if_de.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_de.c,v 1.111 2013/08/07 01:06:34 bluhm Exp $ */ +/* $OpenBSD: if_de.c,v 1.112 2013/11/26 09:50:33 mpi Exp $ */ /* $NetBSD: if_de.c,v 1.58 1998/01/12 09:39:58 thorpej Exp $ */ /*- @@ -2886,6 +2886,7 @@ tulip_free_txmap(tulip_softc_t *sc, bus_dmamap_t map) void tulip_addr_filter(tulip_softc_t * const sc) { + struct arpcom *ac = &sc->tulip_ac; struct ether_multistep step; struct ether_multi *enm; @@ -2915,21 +2916,20 @@ tulip_addr_filter(tulip_softc_t * const sc) * hash and one perfect hardware). */ bzero(sc->tulip_setupdata, sizeof(sc->tulip_setupdata)); - ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); - while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) { + if (ac->ac_multirangecnt > 0) { + sc->tulip_flags |= TULIP_ALLMULTI; + sc->tulip_flags &= ~(TULIP_WANTHASHONLY|TULIP_WANTHASHPERFECT); + } else { + ETHER_FIRST_MULTI(step, ac, enm); + while (enm != NULL) { hash = tulip_mchash(enm->enm_addrlo); #if BYTE_ORDER == BIG_ENDIAN sp[hash >> 4] |= swap32(1 << (hash & 0xF)); #else sp[hash >> 4] |= 1 << (hash & 0xF); #endif - } else { - sc->tulip_flags |= TULIP_ALLMULTI; - sc->tulip_flags &= ~(TULIP_WANTHASHONLY|TULIP_WANTHASHPERFECT); - break; - } ETHER_NEXT_MULTI(step, enm); + } } /* * No reason to use a hash if we are going to be @@ -2965,13 +2965,15 @@ tulip_addr_filter(tulip_softc_t * const sc) if ((sc->tulip_flags & (TULIP_WANTHASHPERFECT|TULIP_WANTHASHONLY)) == 0) { u_int32_t *sp = sc->tulip_setupdata; int idx = 0; + if (ac->ac_multirangecnt > 0) + sc->tulip_flags |= TULIP_ALLMULTI; + if ((sc->tulip_flags & TULIP_ALLMULTI) == 0) { /* * Else can get perfect filtering for 16 addresses. */ - ETHER_FIRST_MULTI(step, &sc->tulip_ac, enm); + ETHER_FIRST_MULTI(step, ac, enm); for (; enm != NULL; idx++) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) { #if BYTE_ORDER == BIG_ENDIAN *sp++ = ((u_int16_t *) enm->enm_addrlo)[0] << 16; *sp++ = ((u_int16_t *) enm->enm_addrlo)[1] << 16; @@ -2981,10 +2983,6 @@ tulip_addr_filter(tulip_softc_t * const sc) *sp++ = ((u_int16_t *) enm->enm_addrlo)[1]; *sp++ = ((u_int16_t *) enm->enm_addrlo)[2]; #endif - } else { - sc->tulip_flags |= TULIP_ALLMULTI; - break; - } ETHER_NEXT_MULTI(step, enm); } /* diff --git a/sys/dev/pci/if_ixgb.c b/sys/dev/pci/if_ixgb.c index 827e9da78f3..9886d39bd40 100644 --- a/sys/dev/pci/if_ixgb.c +++ b/sys/dev/pci/if_ixgb.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_ixgb.c,v 1.59 2011/04/05 18:01:21 henning Exp $ */ +/* $OpenBSD: if_ixgb.c,v 1.60 2013/11/26 09:50:33 mpi Exp $ */ #include <dev/pci/if_ixgb.h> @@ -753,12 +753,14 @@ ixgb_set_multi(struct ixgb_softc *sc) IOCTL_DEBUGOUT("ixgb_set_multi: begin"); + if (ac->ac_multirangecnt > 0) { + ifp->if_flags |= IFF_ALLMULTI; + mcnt = MAX_NUM_MULTICAST_ADDRESSES; + goto setit; + } + 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; - mcnt = MAX_NUM_MULTICAST_ADDRESSES; - } if (mcnt == MAX_NUM_MULTICAST_ADDRESSES) break; bcopy(enm->enm_addrlo, &mta[mcnt*IXGB_ETH_LENGTH_OF_ADDRESS], @@ -767,6 +769,7 @@ ixgb_set_multi(struct ixgb_softc *sc) ETHER_NEXT_MULTI(step, enm); } +setit: if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES) { reg_rctl = IXGB_READ_REG(&sc->hw, RCTL); reg_rctl |= IXGB_RCTL_MPE; diff --git a/sys/dev/pci/if_lge.c b/sys/dev/pci/if_lge.c index 19503c2edef..62c93269c68 100644 --- a/sys/dev/pci/if_lge.c +++ b/sys/dev/pci/if_lge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lge.c,v 1.60 2013/10/01 20:06:01 sf Exp $ */ +/* $OpenBSD: if_lge.c,v 1.61 2013/11/26 09:50:33 mpi Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -325,7 +325,9 @@ lge_setmulti(struct lge_softc *sc) /* Make sure multicast hash table is enabled. */ CSR_WRITE_4(sc, LGE_MODE1, LGE_MODE1_SETRST_CTL1|LGE_MODE1_RX_MCAST); -allmulti: + if (ac->ac_multirangecnt > 0) + ifp->if_flags |= IFF_ALLMULTI; + if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { CSR_WRITE_4(sc, LGE_MAR0, 0xFFFFFFFF); CSR_WRITE_4(sc, LGE_MAR1, 0xFFFFFFFF); @@ -339,10 +341,6 @@ allmulti: /* 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; - } h = (ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26) & 0x0000003F; if (h < 32) diff --git a/sys/dev/pci/if_nge.c b/sys/dev/pci/if_nge.c index c56ebee42c5..d61109555e4 100644 --- a/sys/dev/pci/if_nge.c +++ b/sys/dev/pci/if_nge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nge.c,v 1.77 2013/11/18 19:43:00 brad Exp $ */ +/* $OpenBSD: if_nge.c,v 1.78 2013/11/26 09:50:33 mpi Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -586,7 +586,9 @@ nge_setmulti(struct nge_softc *sc) u_int32_t h = 0, i, filtsave; int bit, index; -allmulti: + if (ac->ac_multirangecnt > 0) + ifp->if_flags |= IFF_ALLMULTI; + if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { NGE_CLRBIT(sc, NGE_RXFILT_CTL, NGE_RXFILTCTL_MCHASH|NGE_RXFILTCTL_UCHASH); @@ -620,10 +622,6 @@ allmulti: */ 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; - } h = (ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 21) & 0x00000FFF; index = (h >> 4) & 0x7F; diff --git a/sys/dev/pci/if_pcn.c b/sys/dev/pci/if_pcn.c index 69eca80d7cd..abaa8bdb68b 100644 --- a/sys/dev/pci/if_pcn.c +++ b/sys/dev/pci/if_pcn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pcn.c,v 1.27 2013/08/07 01:06:36 bluhm Exp $ */ +/* $OpenBSD: if_pcn.c,v 1.28 2013/11/26 09:50:33 mpi Exp $ */ /* $NetBSD: if_pcn.c,v 1.26 2005/05/07 09:15:44 is Exp $ */ /* @@ -1843,7 +1843,8 @@ pcn_set_filter(struct pcn_softc *sc) * of the bits select the bit within the word. */ - if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) + if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC || + ac->ac_multirangecnt > 0) goto allmulti; sc->sc_initblock.init_ladrf[0] = @@ -1853,18 +1854,6 @@ pcn_set_filter(struct pcn_softc *sc) ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) { - if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) { - /* - * We must listen to a range of multicast addresses. - * For now, just accept all multicasts, rather than - * trying to set only those filter bits needed to match - * the range. (At this time, the only use of address - * ranges is for IP multicast routing, for which the - * range is big enough to require all bits set.) - */ - goto allmulti; - } - crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN); /* Just want the 6 most significant bits. */ diff --git a/sys/dev/pci/if_tl.c b/sys/dev/pci/if_tl.c index 1345446be8b..367112c0d88 100644 --- a/sys/dev/pci/if_tl.c +++ b/sys/dev/pci/if_tl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tl.c,v 1.56 2013/11/18 19:43:00 brad Exp $ */ +/* $OpenBSD: if_tl.c,v 1.57 2013/11/26 09:50:33 mpi Exp $ */ /* * Copyright (c) 1997, 1998 @@ -815,20 +815,6 @@ tl_setmulti(struct tl_softc *sc) tl_dio_write32(sc, TL_HASH2, 0); ifp->if_flags &= ~IFF_ALLMULTI; -#if 0 - ETHER_FIRST_MULTI(step, ac, enm); - while (enm != NULL) { - if (memcmp(enm->enm_addrlo, enm->enm_addrhi, 6) == 0) { - h = tl_calchash(enm->enm_addrlo); - hashes[h/32] |= (1 << (h % 32)); - } else { - hashes[0] = hashes[1] = 0xffffffff; - ifp->if_flags |= IFF_ALLMULTI; - break; - } - ETHER_NEXT_MULTI(step, enm); - } -#else ETHER_FIRST_MULTI(step, ac, enm); h = 0; while (enm != NULL) { @@ -840,7 +826,6 @@ tl_setmulti(struct tl_softc *sc) ifp->if_flags |= IFF_ALLMULTI; } else hashes[0] = hashes[1] = 0x00000000; -#endif tl_dio_write32(sc, TL_HASH1, hashes[0]); tl_dio_write32(sc, TL_HASH2, hashes[1]); diff --git a/sys/dev/pci/if_txp.c b/sys/dev/pci/if_txp.c index 015619de47f..c9126fa65e9 100644 --- a/sys/dev/pci/if_txp.c +++ b/sys/dev/pci/if_txp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_txp.c,v 1.107 2013/08/07 01:06:38 bluhm Exp $ */ +/* $OpenBSD: if_txp.c,v 1.108 2013/11/26 09:50:33 mpi Exp $ */ /* * Copyright (c) 2001 @@ -1858,7 +1858,9 @@ txp_set_filter(struct txp_softc *sc) goto setit; } -again: + if (ac->ac_multirangecnt > 0) + ifp->if_flags |= IFF_ALLMULTI; + filter = TXP_RXFILT_DIRECT; if (ifp->if_flags & IFF_BROADCAST) @@ -1871,21 +1873,6 @@ again: ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) { - if (bcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) { - /* - * We must listen to a range of multicast - * addresses. For now, just accept all - * multicasts, rather than trying to set only - * those filter bits needed to match the range. - * (At this time, the only use of address - * ranges is for IP multicast routing, for - * which the range is big enough to require - * all bits set.) - */ - ifp->if_flags |= IFF_ALLMULTI; - goto again; - } - mcnt++; hashbit = (u_int16_t)(ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) & (64 - 1)); diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c index 74ffbb3198f..70afc260646 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.54 2013/10/01 20:06:02 sf Exp $ */ +/* $OpenBSD: if_wb.c,v 1.55 2013/11/26 09:50:33 mpi Exp $ */ /* * Copyright (c) 1997, 1998 @@ -537,7 +537,9 @@ void wb_setmulti(sc) rxfilt = CSR_READ_4(sc, WB_NETCFG); -allmulti: + if (ac->ac_multirangecnt > 0) + ifp->if_flags |= IFF_ALLMULTI; + if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) { rxfilt |= WB_NETCFG_RX_MULTI; CSR_WRITE_4(sc, WB_NETCFG, rxfilt); @@ -553,10 +555,6 @@ allmulti: /* 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; - } h = ~(ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26); if (h < 32) hashes[0] |= (1 << h); diff --git a/sys/dev/pci/if_xge.c b/sys/dev/pci/if_xge.c index 55ba58cb87e..bd286e36740 100644 --- a/sys/dev/pci/if_xge.c +++ b/sys/dev/pci/if_xge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_xge.c,v 1.55 2013/08/07 01:06:39 bluhm Exp $ */ +/* $OpenBSD: if_xge.c,v 1.56 2013/11/26 09:50:33 mpi Exp $ */ /* $NetBSD: if_xge.c,v 1.1 2005/09/09 10:30:27 ragge Exp $ */ /* @@ -1016,12 +1016,11 @@ xge_setmulti(struct xge_softc *sc) int i, numaddr = 1; /* first slot used for card unicast address */ uint64_t val; + if (ac->ac_multirangecnt > 0) + goto allmulti; + ETHER_FIRST_MULTI(step, ac, enm); while (enm != NULL) { - if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) { - /* Skip ranges */ - goto allmulti; - } if (numaddr == MAX_MCAST_ADDR) goto allmulti; for (val = 0, i = 0; i < ETHER_ADDR_LEN; i++) { |