Date: Mon, 21 Oct 2019 18:06:27 +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: r353812 - head/sys/dev/bge Message-ID: <201910211806.x9LI6RQL065076@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Mon Oct 21 18:06:26 2019 New Revision: 353812 URL: https://svnweb.freebsd.org/changeset/base/353812 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/bge/if_bge.c Modified: head/sys/dev/bge/if_bge.c ============================================================================== --- head/sys/dev/bge/if_bge.c Mon Oct 21 18:06:23 2019 (r353811) +++ head/sys/dev/bge/if_bge.c Mon Oct 21 18:06:26 2019 (r353812) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910211806.x9LI6RQL065076>