From owner-svn-src-head@freebsd.org Mon Oct 21 18:07:58 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 17E0B15D848; Mon, 21 Oct 2019 18:07:58 +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 46xl3x44X1z4Zm5; Mon, 21 Oct 2019 18:07:57 +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 DF19327B64; Mon, 21 Oct 2019 18:07:56 +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 x9LI7ues065966; Mon, 21 Oct 2019 18:07:56 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LI7uts065965; Mon, 21 Oct 2019 18:07:56 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211807.x9LI7uts065965@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:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353829 - head/sys/dev/stge X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/stge X-SVN-Commit-Revision: 353829 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:58 -0000 Author: glebius Date: Mon Oct 21 18:07:56 2019 New Revision: 353829 URL: https://svnweb.freebsd.org/changeset/base/353829 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/stge/if_stge.c Modified: head/sys/dev/stge/if_stge.c ============================================================================== --- head/sys/dev/stge/if_stge.c Mon Oct 21 18:07:53 2019 (r353828) +++ head/sys/dev/stge/if_stge.c Mon Oct 21 18:07:56 2019 (r353829) @@ -2507,12 +2507,24 @@ stge_set_filter(struct stge_softc *sc) CSR_WRITE_2(sc, STGE_ReceiveMode, mode); } +static u_int +stge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t crc, *mchash = arg; + + crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN); + /* Just want the 6 least significant bits. */ + crc &= 0x3f; + /* Set the corresponding bit in the hash table. */ + mchash[crc >> 5] |= 1 << (crc & 0x1f); + + return (1); +} + static void stge_set_multi(struct stge_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; - uint32_t crc; uint32_t mchash[2]; uint16_t mode; int count; @@ -2542,25 +2554,8 @@ stge_set_multi(struct stge_softc *sc) * high order bits select the register, while the rest of the bits * select the bit within the register. */ - bzero(mchash, sizeof(mchash)); - - count = 0; - if_maddr_rlock(sc->sc_ifp); - CK_STAILQ_FOREACH(ifma, &sc->sc_ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - crc = ether_crc32_be(LLADDR((struct sockaddr_dl *) - ifma->ifma_addr), ETHER_ADDR_LEN); - - /* Just want the 6 least significant bits. */ - crc &= 0x3f; - - /* Set the corresponding bit in the hash table. */ - mchash[crc >> 5] |= 1 << (crc & 0x1f); - count++; - } - if_maddr_runlock(ifp); + count = if_foreach_llmaddr(ifp, stge_hash_maddr, mchash); mode &= ~(RM_ReceiveMulticast | RM_ReceiveAllFrames); if (count > 0)