From owner-svn-src-all@freebsd.org Mon Oct 21 18:12:09 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 4EDB715E27E; Mon, 21 Oct 2019 18:12:09 +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 46xl8m6VYpz4f2c; Mon, 21 Oct 2019 18:12:08 +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 9D28827D09; Mon, 21 Oct 2019 18:12:07 +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 x9LIC7Iu072466; Mon, 21 Oct 2019 18:12:07 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LIC7gl072465; Mon, 21 Oct 2019 18:12:07 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211812.x9LIC7gl072465@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:12:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353853 - head/sys/dev/otus X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/otus X-SVN-Commit-Revision: 353853 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:12:09 -0000 Author: glebius Date: Mon Oct 21 18:12:07 2019 New Revision: 353853 URL: https://svnweb.freebsd.org/changeset/base/353853 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/otus/if_otus.c Modified: head/sys/dev/otus/if_otus.c ============================================================================== --- head/sys/dev/otus/if_otus.c Mon Oct 21 18:12:02 2019 (r353852) +++ head/sys/dev/otus/if_otus.c Mon Oct 21 18:12:07 2019 (r353853) @@ -2308,63 +2308,63 @@ otus_tx(struct otus_softc *sc, struct ieee80211_node * return 0; } +static u_int +otus_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t val, *hashes = arg; + + val = le32dec(LLADDR(sdl) + 4); + /* Get address byte 5 */ + val = val & 0x0000ff00; + val = val >> 8; + + /* As per below, shift it >> 2 to get only 6 bits */ + val = val >> 2; + if (val < 32) + hashes[0] |= 1 << val; + else + hashes[1] |= 1 << (val - 32); + + return (1); +} + + int otus_set_multi(struct otus_softc *sc) { - uint32_t lo, hi; struct ieee80211com *ic = &sc->sc_ic; + uint32_t hashes[2]; int r; if (ic->ic_allmulti > 0 || ic->ic_promisc > 0 || ic->ic_opmode == IEEE80211_M_MONITOR) { - lo = 0xffffffff; - hi = 0xffffffff; + hashes[0] = 0xffffffff; + hashes[1] = 0xffffffff; } else { struct ieee80211vap *vap; - struct ifnet *ifp; - struct ifmultiaddr *ifma; - lo = hi = 0; - TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) { - ifp = vap->iv_ifp; - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - caddr_t dl; - uint32_t val; - - dl = LLADDR((struct sockaddr_dl *) ifma->ifma_addr); - val = le32dec(dl + 4); - /* Get address byte 5 */ - val = val & 0x0000ff00; - val = val >> 8; - - /* As per below, shift it >> 2 to get only 6 bits */ - val = val >> 2; - if (val < 32) - lo |= 1 << val; - else - hi |= 1 << (val - 32); - } - if_maddr_runlock(ifp); - } + hashes[0] = hashes[1] = 0; + TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) + if_foreach_llmaddr(vap->iv_ifp, otus_hash_maddr, + hashes); } #if 0 /* XXX openbsd code */ while (enm != NULL) { bit = enm->enm_addrlo[5] >> 2; if (bit < 32) - lo |= 1 << bit; + hashes[0] |= 1 << bit; else - hi |= 1 << (bit - 32); + hashes[1] |= 1 << (bit - 32); ETHER_NEXT_MULTI(step, enm); } #endif - hi |= 1U << 31; /* Make sure the broadcast bit is set. */ + hashes[1] |= 1U << 31; /* Make sure the broadcast bit is set. */ OTUS_LOCK(sc); - otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_L, lo); - otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_H, hi); + otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_L, hashes[0]); + otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_H, hashes[1]); r = otus_write_barrier(sc); /* XXX operating mode? filter? */ OTUS_UNLOCK(sc);