Date: Mon, 21 Oct 2019 18:13:14 +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: r353862 - head/sys/arm/allwinner Message-ID: <201910211813.x9LIDE0P072936@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Mon Oct 21 18:13:14 2019 New Revision: 353862 URL: https://svnweb.freebsd.org/changeset/base/353862 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/arm/allwinner/if_awg.c Modified: head/sys/arm/allwinner/if_awg.c ============================================================================== --- head/sys/arm/allwinner/if_awg.c Mon Oct 21 18:12:58 2019 (r353861) +++ head/sys/arm/allwinner/if_awg.c Mon Oct 21 18:13:14 2019 (r353862) @@ -675,12 +675,25 @@ bitrev32(uint32_t x) return (x >> 16) | (x << 16); } +static u_int +awg_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t crc, hashreg, hashbit, *hash = arg; + + crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0x7f; + crc = bitrev32(~crc) >> 26; + hashreg = (crc >> 5); + hashbit = (crc & 0x1f); + hash[hashreg] |= (1 << hashbit); + + return (1); +} + static void awg_setup_rxfilter(struct awg_softc *sc) { - uint32_t val, crc, hashreg, hashbit, hash[2], machi, maclo; - int mc_count, mcnt, i; - uint8_t *eaddr, *mta; + uint32_t val, hash[2], machi, maclo; + uint8_t *eaddr; if_t ifp; AWG_ASSERT_LOCKED(sc); @@ -689,36 +702,13 @@ awg_setup_rxfilter(struct awg_softc *sc) val = 0; hash[0] = hash[1] = 0; - mc_count = if_multiaddr_count(ifp, -1); - if (if_getflags(ifp) & IFF_PROMISC) val |= DIS_ADDR_FILTER; else if (if_getflags(ifp) & IFF_ALLMULTI) { val |= RX_ALL_MULTICAST; hash[0] = hash[1] = ~0; - } else if (mc_count > 0) { + } else if (if_foreach_llmaddr(ifp, awg_hash_maddr, hash) > 0) val |= HASH_MULTICAST; - - mta = malloc(sizeof(unsigned char) * ETHER_ADDR_LEN * mc_count, - M_DEVBUF, M_NOWAIT); - if (mta == NULL) { - if_printf(ifp, - "failed to allocate temporary multicast list\n"); - return; - } - - if_multiaddr_array(ifp, mta, &mcnt, mc_count); - for (i = 0; i < mcnt; i++) { - crc = ether_crc32_le(mta + (i * ETHER_ADDR_LEN), - ETHER_ADDR_LEN) & 0x7f; - crc = bitrev32(~crc) >> 26; - hashreg = (crc >> 5); - hashbit = (crc & 0x1f); - hash[hashreg] |= (1 << hashbit); - } - - free(mta, M_DEVBUF); - } /* Write our unicast address */ eaddr = IF_LLADDR(ifp);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910211813.x9LIDE0P072936>