Date: Mon, 21 Oct 2019 18:11:28 +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: r353845 - head/sys/dev/et Message-ID: <201910211811.x9LIBSjG068310@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Mon Oct 21 18:11:28 2019 New Revision: 353845 URL: https://svnweb.freebsd.org/changeset/base/353845 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/et/if_et.c Modified: head/sys/dev/et/if_et.c ============================================================================== --- head/sys/dev/et/if_et.c Mon Oct 21 18:11:24 2019 (r353844) +++ head/sys/dev/et/if_et.c Mon Oct 21 18:11:28 2019 (r353845) @@ -1560,13 +1560,36 @@ et_free_rx_ring(struct et_softc *sc) } } +static u_int +et_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t h, *hp, *hash = arg; + + h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN); + h = (h & 0x3f800000) >> 23; + + hp = &hash[0]; + if (h >= 32 && h < 64) { + h -= 32; + hp = &hash[1]; + } else if (h >= 64 && h < 96) { + h -= 64; + hp = &hash[2]; + } else if (h >= 96) { + h -= 96; + hp = &hash[3]; + } + *hp |= (1 << h); + + return (1); +} + static void et_setmulti(struct et_softc *sc) { struct ifnet *ifp; uint32_t hash[4] = { 0, 0, 0, 0 }; uint32_t rxmac_ctrl, pktfilt; - struct ifmultiaddr *ifma; int i, count; ET_LOCK_ASSERT(sc); @@ -1581,34 +1604,7 @@ et_setmulti(struct et_softc *sc) goto back; } - count = 0; - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - uint32_t *hp, h; - - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - - h = ether_crc32_be(LLADDR((struct sockaddr_dl *) - ifma->ifma_addr), ETHER_ADDR_LEN); - h = (h & 0x3f800000) >> 23; - - hp = &hash[0]; - if (h >= 32 && h < 64) { - h -= 32; - hp = &hash[1]; - } else if (h >= 64 && h < 96) { - h -= 64; - hp = &hash[2]; - } else if (h >= 96) { - h -= 96; - hp = &hash[3]; - } - *hp |= (1 << h); - - ++count; - } - if_maddr_runlock(ifp); + count = if_foreach_llmaddr(ifp, et_hash_maddr, &hash); for (i = 0; i < 4; ++i) CSR_WRITE_4(sc, ET_MULTI_HASH + (i * 4), hash[i]);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910211811.x9LIBSjG068310>