From owner-svn-src-all@freebsd.org Mon Oct 21 18:11:29 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 B81BD15E101; Mon, 21 Oct 2019 18:11:29 +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 46xl812PWgz4d5Y; Mon, 21 Oct 2019 18:11:29 +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 E049327BD3; Mon, 21 Oct 2019 18:11:28 +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 x9LIBS0Q068311; Mon, 21 Oct 2019 18:11:28 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LIBSjG068310; Mon, 21 Oct 2019 18:11:28 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211811.x9LIBSjG068310@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:11:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353845 - head/sys/dev/et X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/et X-SVN-Commit-Revision: 353845 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:11:29 -0000 Author: glebius Date: Mon Oct 21 18:11:28 2019 New Revision: 353845 URL: https://svnweb.freebsd.org/changeset/base/353845 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/et/if_et.c Modified: head/sys/dev/et/if_et.c ============================================================================== --- head/sys/dev/et/if_et.c Mon Oct 21 18:11:24 2019 (r353844) +++ head/sys/dev/et/if_et.c Mon Oct 21 18:11:28 2019 (r353845) @@ -1560,13 +1560,36 @@ et_free_rx_ring(struct et_softc *sc) } } +static u_int +et_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t h, *hp, *hash = arg; + + h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN); + h = (h & 0x3f800000) >> 23; + + hp = &hash[0]; + if (h >= 32 && h < 64) { + h -= 32; + hp = &hash[1]; + } else if (h >= 64 && h < 96) { + h -= 64; + hp = &hash[2]; + } else if (h >= 96) { + h -= 96; + hp = &hash[3]; + } + *hp |= (1 << h); + + return (1); +} + static void et_setmulti(struct et_softc *sc) { struct ifnet *ifp; uint32_t hash[4] = { 0, 0, 0, 0 }; uint32_t rxmac_ctrl, pktfilt; - struct ifmultiaddr *ifma; int i, count; ET_LOCK_ASSERT(sc); @@ -1581,34 +1604,7 @@ et_setmulti(struct et_softc *sc) goto back; } - count = 0; - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - uint32_t *hp, h; - - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - - h = ether_crc32_be(LLADDR((struct sockaddr_dl *) - ifma->ifma_addr), ETHER_ADDR_LEN); - h = (h & 0x3f800000) >> 23; - - hp = &hash[0]; - if (h >= 32 && h < 64) { - h -= 32; - hp = &hash[1]; - } else if (h >= 64 && h < 96) { - h -= 64; - hp = &hash[2]; - } else if (h >= 96) { - h -= 96; - hp = &hash[3]; - } - *hp |= (1 << h); - - ++count; - } - if_maddr_runlock(ifp); + count = if_foreach_llmaddr(ifp, et_hash_maddr, &hash); for (i = 0; i < 4; ++i) CSR_WRITE_4(sc, ET_MULTI_HASH + (i * 4), hash[i]);