From owner-svn-src-all@freebsd.org Mon Oct 14 20:29:51 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 928CF136BA3; Mon, 14 Oct 2019 20:29:51 +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 46sVXv3Npdz3MDp; Mon, 14 Oct 2019 20:29:51 +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 3F9B3A91D; Mon, 14 Oct 2019 20:29:51 +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 x9EKTpw1070532; Mon, 14 Oct 2019 20:29:51 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9EKTp3S070531; Mon, 14 Oct 2019 20:29:51 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910142029.x9EKTp3S070531@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: glebius set sender to glebius@FreeBSD.org using -f From: Gleb Smirnoff Date: Mon, 14 Oct 2019 20:29:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353510 - head/sys/dev/usb/net X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/usb/net X-SVN-Commit-Revision: 353510 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, 14 Oct 2019 20:29:51 -0000 Author: glebius Date: Mon Oct 14 20:29:50 2019 New Revision: 353510 URL: https://svnweb.freebsd.org/changeset/base/353510 Log: Convert to if_foreach_llmaddr() KPI. Reviewed by: hselasky Modified: head/sys/dev/usb/net/if_smsc.c Modified: head/sys/dev/usb/net/if_smsc.c ============================================================================== --- head/sys/dev/usb/net/if_smsc.c Mon Oct 14 20:29:32 2019 (r353509) +++ head/sys/dev/usb/net/if_smsc.c Mon Oct 14 20:29:50 2019 (r353510) @@ -691,6 +691,18 @@ smsc_hash(uint8_t addr[ETHER_ADDR_LEN]) return (ether_crc32_be(addr, ETHER_ADDR_LEN) >> 26) & 0x3f; } +static u_int +smsc_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint32_t hash, *hashtbl = arg; + + hash = smsc_hash(LLADDR(sdl)); + hashtbl[hash >> 5] |= 1 << (hash & 0x1F); + + return (1); +} + + /** * smsc_setmulti - Setup multicast * @ue: usb ethernet device context @@ -706,9 +718,7 @@ smsc_setmulti(struct usb_ether *ue) { struct smsc_softc *sc = uether_getsc(ue); struct ifnet *ifp = uether_getifp(ue); - struct ifmultiaddr *ifma; uint32_t hashtbl[2] = { 0, 0 }; - uint32_t hash; SMSC_LOCK_ASSERT(sc, MA_OWNED); @@ -718,29 +728,19 @@ smsc_setmulti(struct usb_ether *ue) sc->sc_mac_csr &= ~SMSC_MAC_CSR_HPFILT; } else { - /* Take the lock of the mac address list before hashing each of them */ - if_maddr_rlock(ifp); - - if (!CK_STAILQ_EMPTY(&ifp->if_multiaddrs)) { - /* We are filtering on a set of address so calculate hashes of each - * of the address and set the corresponding bits in the register. + if (if_foreach_llmaddr(ifp, smsc_hash_maddr, &hashtbl) > 0) { + /* We are filtering on a set of address so calculate + * hashes of each of the address and set the + * corresponding bits in the register. */ sc->sc_mac_csr |= SMSC_MAC_CSR_HPFILT; sc->sc_mac_csr &= ~(SMSC_MAC_CSR_PRMS | SMSC_MAC_CSR_MCPAS); - - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - - hash = smsc_hash(LLADDR((struct sockaddr_dl *)ifma->ifma_addr)); - hashtbl[hash >> 5] |= 1 << (hash & 0x1F); - } } else { - /* Only receive packets with destination set to our mac address */ + /* Only receive packets with destination set to + * our mac address + */ sc->sc_mac_csr &= ~(SMSC_MAC_CSR_MCPAS | SMSC_MAC_CSR_HPFILT); } - - if_maddr_runlock(ifp); /* Debug */ if (sc->sc_mac_csr & SMSC_MAC_CSR_HPFILT)