From 5b7a9eab16e1537d27a2b1d499c76178994b11e5 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Mon, 21 Oct 2019 18:10:46 +0000 Subject: [PATCH] Convert to if_foreach_llmaddr() KPI. --- sys/dev/altera/atse/if_atse.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/sys/dev/altera/atse/if_atse.c b/sys/dev/altera/atse/if_atse.c index 6756f92ad1f1..c84194868ec4 100644 --- a/sys/dev/altera/atse/if_atse.c +++ b/sys/dev/altera/atse/if_atse.c @@ -427,12 +427,14 @@ atse_stop_locked(struct atse_softc *sc) return (0); } -static uint8_t -atse_mchash(struct atse_softc *sc __unused, const uint8_t *addr) +static u_int +atse_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) { - uint8_t x, y; + uint64_t *h = arg; + uint8_t *addr, x, y; int i, j; + addr = LLADDR(sdl); x = 0; for (i = 0; i < ETHER_ADDR_LEN; i++) { y = addr[i] & 0x01; @@ -440,14 +442,14 @@ atse_mchash(struct atse_softc *sc __unused, const uint8_t *addr) y ^= (addr[i] >> j) & 0x01; x |= (y << i); } + *h |= (1 << x); - return (x); + return (1); } static int atse_rxfilter_locked(struct atse_softc *sc) { - struct ifmultiaddr *ifma; struct ifnet *ifp; uint32_t val4; int i; @@ -478,22 +480,13 @@ atse_rxfilter_locked(struct atse_softc *sc) */ uint64_t h; - h = 0; /* * Re-build and re-program hash table. First build the * bit-field "yes" or "no" for each slot per address, then * do all the programming afterwards. */ - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) { - continue; - } - - h |= (1 << atse_mchash(sc, - LLADDR((struct sockaddr_dl *)ifma->ifma_addr))); - } - if_maddr_runlock(ifp); + h = 0; + (void)if_foreach_llmaddr(ifp, atse_hash_maddr, &h); for (i = 0; i <= MHASH_LEN; i++) { CSR_WRITE_4(sc, MHASH_START + i, (h & (1 << i)) ? 0x01 : 0x00);