Date: Mon, 21 Oct 2019 18:13:19 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353863 - head/sys/arm/allwinner Message-ID: <201910211813.x9LIDJ0F072988@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Mon Oct 21 18:13:19 2019 New Revision: 353863 URL: https://svnweb.freebsd.org/changeset/base/353863 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/arm/allwinner/if_emac.c Modified: head/sys/arm/allwinner/if_emac.c ============================================================================== --- head/sys/arm/allwinner/if_emac.c Mon Oct 21 18:13:14 2019 (r353862) +++ head/sys/arm/allwinner/if_emac.c Mon Oct 21 18:13:19 2019 (r353863) @@ -218,12 +218,22 @@ emac_get_hwaddr(struct emac_softc *sc, uint8_t *hwaddr printf("MAC address: %s\n", ether_sprintf(hwaddr)); } +static u_int +emac_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t h, *hashes = arg; + + h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26; + hashes[h >> 5] |= 1 << (h & 0x1f); + + return (1); +} + static void emac_set_rx_mode(struct emac_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; - uint32_t h, hashes[2]; + uint32_t hashes[2]; uint32_t rcr = 0; EMAC_ASSERT_LOCKED(sc); @@ -241,17 +251,8 @@ emac_set_rx_mode(struct emac_softc *sc) if (ifp->if_flags & IFF_ALLMULTI) { hashes[0] = 0xffffffff; hashes[1] = 0xffffffff; - } else { - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &sc->emac_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) >> 26; - hashes[h >> 5] |= 1 << (h & 0x1f); - } - if_maddr_runlock(ifp); - } + } else + if_foreach_llmaddr(ifp, emac_hash_maddr, hashes); rcr |= EMAC_RX_MCO; rcr |= EMAC_RX_MHF; EMAC_WRITE_REG(sc, EMAC_RX_HASH0, hashes[0]);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910211813.x9LIDJ0F072988>