From 0322ca23bca69c1232306576f48c2747c655dc0b Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Mon, 21 Oct 2019 18:06:26 +0000 Subject: [PATCH] Convert to if_foreach_llmaddr() KPI. --- sys/dev/bge/if_bge.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 30b8c9ac76b..6199478c4b2 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -1621,33 +1621,32 @@ bge_setpromisc(struct bge_softc *sc) BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_RX_PROMISC); } +static u_int +bge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t *hashes = arg; + int h; + + h = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0x7F; + hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F); + + return (1); +} + static void bge_setmulti(struct bge_softc *sc) { if_t ifp; - int mc_count = 0; uint32_t hashes[4] = { 0, 0, 0, 0 }; - int h, i, mcnt; - unsigned char *mta; + int i; BGE_LOCK_ASSERT(sc); ifp = sc->bge_ifp; - mc_count = if_multiaddr_count(ifp, -1); - mta = malloc(sizeof(unsigned char) * ETHER_ADDR_LEN * - mc_count, M_DEVBUF, M_NOWAIT); - - if(mta == NULL) { - device_printf(sc->bge_dev, - "Failed to allocated temp mcast list\n"); - return; - } - if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) { for (i = 0; i < 4; i++) CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0xFFFFFFFF); - free(mta, M_DEVBUF); return; } @@ -1655,17 +1654,10 @@ bge_setmulti(struct bge_softc *sc) for (i = 0; i < 4; i++) CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0); - if_multiaddr_array(ifp, mta, &mcnt, mc_count); - for(i = 0; i < mcnt; i++) { - h = ether_crc32_le(mta + (i * ETHER_ADDR_LEN), - ETHER_ADDR_LEN) & 0x7F; - hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F); - } + if_foreach_llmaddr(ifp, bge_hash_maddr, hashes); for (i = 0; i < 4; i++) CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), hashes[i]); - - free(mta, M_DEVBUF); } static void