From owner-svn-src-all@freebsd.org Mon Oct 21 18:06:58 2019 Return-Path: Delivered-To: svn-src-all@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 B1EE215D36D; Mon, 21 Oct 2019 18:06: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 46xl2p0Jmcz4Y82; Mon, 21 Oct 2019 18:06:58 +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 DE6DD27B56; Mon, 21 Oct 2019 18:06:57 +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 x9LI6vrv065250; Mon, 21 Oct 2019 18:06:57 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LI6v9b065249; Mon, 21 Oct 2019 18:06:57 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211806.x9LI6v9b065249@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:06:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353815 - head/sys/dev/gem X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/gem X-SVN-Commit-Revision: 353815 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 18:06:58 -0000 Author: glebius Date: Mon Oct 21 18:06:57 2019 New Revision: 353815 URL: https://svnweb.freebsd.org/changeset/base/353815 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/gem/if_gem.c Modified: head/sys/dev/gem/if_gem.c ============================================================================== --- head/sys/dev/gem/if_gem.c Mon Oct 21 18:06:53 2019 (r353814) +++ head/sys/dev/gem/if_gem.c Mon Oct 21 18:06:57 2019 (r353815) @@ -2202,14 +2202,27 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) return (error); } +static u_int +gem_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t crc, *hash = arg; + + crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN); + /* We just want the 8 most significant bits. */ + crc >>= 24; + /* Set the corresponding bit in the filter. */ + hash[crc >> 4] |= 1 << (15 - (crc & 15)); + + return (1); +} + static void gem_setladrf(struct gem_softc *sc) { struct ifnet *ifp = sc->sc_ifp; - struct ifmultiaddr *inm; int i; uint32_t hash[16]; - uint32_t crc, v; + uint32_t v; GEM_LOCK_ASSERT(sc, MA_OWNED); @@ -2245,23 +2258,8 @@ gem_setladrf(struct gem_softc *sc) * is the MSB). */ - /* Clear the hash table. */ memset(hash, 0, sizeof(hash)); - - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) { - if (inm->ifma_addr->sa_family != AF_LINK) - continue; - crc = ether_crc32_le(LLADDR((struct sockaddr_dl *) - inm->ifma_addr), ETHER_ADDR_LEN); - - /* We just want the 8 most significant bits. */ - crc >>= 24; - - /* Set the corresponding bit in the filter. */ - hash[crc >> 4] |= 1 << (15 - (crc & 15)); - } - if_maddr_runlock(ifp); + if_foreach_llmaddr(ifp, gem_hash_maddr, hash); v |= GEM_MAC_RX_HASH_FILTER;