Author: glebius Date: Mon Oct 21 18:07:28 2019 New Revision: 353822 URL: https://svnweb.freebsd.org/changeset/base/353822
Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/nge/if_nge.c Modified: head/sys/dev/nge/if_nge.c ============================================================================== --- head/sys/dev/nge/if_nge.c Mon Oct 21 18:07:24 2019 (r353821) +++ head/sys/dev/nge/if_nge.c Mon Oct 21 18:07:28 2019 (r353822) @@ -661,13 +661,33 @@ nge_miibus_statchg(device_t dev) CSR_READ_4(sc, NGE_GPIO) & ~NGE_GPIO_GP3_OUT); } +static u_int +nge_write_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + struct nge_softc *sc = arg; + uint32_t h; + int bit, index; + + /* + * From the 11 bits returned by the crc routine, the top 7 + * bits represent the 16-bit word in the mcast hash table + * that needs to be updated, and the lower 4 bits represent + * which bit within that byte needs to be set. + */ + h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 21; + index = (h >> 4) & 0x7F; + bit = h & 0xF; + CSR_WRITE_4(sc, NGE_RXFILT_CTL, NGE_FILTADDR_MCAST_LO + (index * 2)); + NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit)); + + return (1); +} + static void nge_rxfilter(struct nge_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; - uint32_t h, i, rxfilt; - int bit, index; + uint32_t i, rxfilt; NGE_LOCK_ASSERT(sc); ifp = sc->nge_ifp; @@ -720,26 +740,7 @@ nge_rxfilter(struct nge_softc *sc) CSR_WRITE_4(sc, NGE_RXFILT_DATA, 0); } - /* - * From the 11 bits returned by the crc routine, the top 7 - * bits represent the 16-bit word in the mcast hash table - * that needs to be updated, and the lower 4 bits represent - * which bit within that byte needs to be set. - */ - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - h = ether_crc32_be(LLADDR((struct sockaddr_dl *) - ifma->ifma_addr), ETHER_ADDR_LEN) >> 21; - index = (h >> 4) & 0x7F; - bit = h & 0xF; - CSR_WRITE_4(sc, NGE_RXFILT_CTL, - NGE_FILTADDR_MCAST_LO + (index * 2)); - NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit)); - } - if_maddr_runlock(ifp); - + if_foreach_llmaddr(ifp, nge_write_maddr, sc); done: CSR_WRITE_4(sc, NGE_RXFILT_CTL, rxfilt); /* Turn the receive filter on. */ _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"