From owner-svn-src-head@freebsd.org Mon Oct 21 18:07:45 2019 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8829D15D738; Mon, 21 Oct 2019 18:07:45 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46xl3j2l4pz4ZRg; Mon, 21 Oct 2019 18:07:45 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3848727B61; Mon, 21 Oct 2019 18:07:45 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x9LI7j0r065816; Mon, 21 Oct 2019 18:07:45 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LI7j69065815; Mon, 21 Oct 2019 18:07:45 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211807.x9LI7j69065815@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 21 Oct 2019 18:07:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353826 - head/sys/dev/sis X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/sis X-SVN-Commit-Revision: 353826 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 18:07:45 -0000 Author: glebius Date: Mon Oct 21 18:07:44 2019 New Revision: 353826 URL: https://svnweb.freebsd.org/changeset/base/353826 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/sis/if_sis.c Modified: head/sys/dev/sis/if_sis.c ============================================================================== --- head/sys/dev/sis/if_sis.c Mon Oct 21 18:07:40 2019 (r353825) +++ head/sys/dev/sis/if_sis.c Mon Oct 21 18:07:44 2019 (r353826) @@ -694,13 +694,29 @@ sis_rxfilter(struct sis_softc *sc) sis_rxfilter_sis(sc); } +static u_int +sis_write_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + struct sis_softc *sc = arg; + uint32_t h; + int bit, index; + + h = sis_mchash(sc, LLADDR(sdl)); + index = h >> 3; + bit = h & 0x1F; + CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + index); + if (bit > 0xF) + bit -= 0x10; + SIS_SETBIT(sc, SIS_RXFILT_DATA, (1 << bit)); + + return (1); +} + static void sis_rxfilter_ns(struct sis_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; - uint32_t h, i, filter; - int bit, index; + uint32_t i, filter; ifp = sc->sis_ifp; filter = CSR_READ_4(sc, SIS_RXFILT_CTL); @@ -743,21 +759,7 @@ sis_rxfilter_ns(struct sis_softc *sc) CSR_WRITE_4(sc, SIS_RXFILT_DATA, 0); } - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - h = sis_mchash(sc, - LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); - index = h >> 3; - bit = h & 0x1F; - CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + - index); - if (bit > 0xF) - bit -= 0x10; - SIS_SETBIT(sc, SIS_RXFILT_DATA, (1 << bit)); - } - if_maddr_runlock(ifp); + if_foreach_llmaddr(ifp, sis_write_maddr, sc); } /* Turn the receive filter on */ @@ -765,13 +767,29 @@ sis_rxfilter_ns(struct sis_softc *sc) CSR_READ_4(sc, SIS_RXFILT_CTL); } +struct sis_hash_maddr_ctx { + struct sis_softc *sc; + uint16_t hashes[16]; +}; + +static u_int +sis_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + struct sis_hash_maddr_ctx *ctx = arg; + uint32_t h; + + h = sis_mchash(ctx->sc, LLADDR(sdl)); + ctx->hashes[h >> 4] |= 1 << (h & 0xf); + + return (1); +} + static void sis_rxfilter_sis(struct sis_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; - uint32_t filter, h, i, n; - uint16_t hashes[16]; + struct sis_hash_maddr_ctx ctx; + uint32_t filter, i, n; ifp = sc->sis_ifp; @@ -796,31 +814,21 @@ sis_rxfilter_sis(struct sis_softc *sc) if (ifp->if_flags & IFF_PROMISC) filter |= SIS_RXFILTCTL_ALLPHYS; for (i = 0; i < n; i++) - hashes[i] = ~0; + ctx.hashes[i] = ~0; } else { for (i = 0; i < n; i++) - hashes[i] = 0; - i = 0; - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - h = sis_mchash(sc, - LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); - hashes[h >> 4] |= 1 << (h & 0xf); - i++; - } - if_maddr_runlock(ifp); - if (i > n) { + ctx.hashes[i] = 0; + ctx.sc = sc; + if (if_foreach_llmaddr(ifp, sis_hash_maddr, &ctx) > n) { filter |= SIS_RXFILTCTL_ALLMULTI; for (i = 0; i < n; i++) - hashes[i] = ~0; + ctx.hashes[i] = ~0; } } for (i = 0; i < n; i++) { CSR_WRITE_4(sc, SIS_RXFILT_CTL, (4 + i) << 16); - CSR_WRITE_4(sc, SIS_RXFILT_DATA, hashes[i]); + CSR_WRITE_4(sc, SIS_RXFILT_DATA, ctx.hashes[i]); } /* Turn the receive filter on */