From owner-svn-src-all@freebsd.org Mon Oct 21 18:08:25 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 DABCD15DA2E; Mon, 21 Oct 2019 18:08:25 +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 46xl4T4ktKz4bSF; Mon, 21 Oct 2019 18:08:25 +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 8528027B69; Mon, 21 Oct 2019 18:08:25 +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 x9LI8Psx066230; Mon, 21 Oct 2019 18:08:25 GMT (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x9LI8Pa8066229; Mon, 21 Oct 2019 18:08:25 GMT (envelope-from glebius@FreeBSD.org) Message-Id: <201910211808.x9LI8Pa8066229@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:08:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353834 - head/sys/dev/xl X-SVN-Group: head X-SVN-Commit-Author: glebius X-SVN-Commit-Paths: head/sys/dev/xl X-SVN-Commit-Revision: 353834 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:08:26 -0000 Author: glebius Date: Mon Oct 21 18:08:25 2019 New Revision: 353834 URL: https://svnweb.freebsd.org/changeset/base/353834 Log: Convert to if_foreach_llmaddr() KPI. Modified: head/sys/dev/xl/if_xl.c Modified: head/sys/dev/xl/if_xl.c ============================================================================== --- head/sys/dev/xl/if_xl.c Mon Oct 21 18:08:20 2019 (r353833) +++ head/sys/dev/xl/if_xl.c Mon Oct 21 18:08:25 2019 (r353834) @@ -606,11 +606,20 @@ xl_rxfilter(struct xl_softc *sc) * NICs older than the 3c905B have only one multicast option, which * is to enable reception of all multicast frames. */ +static u_int +xl_check_maddr_90x(void *arg, struct sockaddr_dl *sdl, u_int cnt) +{ + uint8_t *rxfilt = arg; + + *rxfilt |= XL_RXFILTER_ALLMULTI; + + return (1); +} + static void xl_rxfilter_90x(struct xl_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; u_int8_t rxfilt; XL_LOCK_ASSERT(sc); @@ -634,16 +643,8 @@ xl_rxfilter_90x(struct xl_softc *sc) rxfilt |= XL_RXFILTER_ALLFRAMES; if (ifp->if_flags & IFF_ALLMULTI) rxfilt |= XL_RXFILTER_ALLMULTI; - } else { - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - rxfilt |= XL_RXFILTER_ALLMULTI; - break; - } - if_maddr_runlock(ifp); - } + } else + if_foreach_llmaddr(sc->xl_ifp, xl_check_maddr_90x, &rxfilt); CSR_WRITE_2(sc, XL_COMMAND, rxfilt | XL_CMD_RX_SET_FILT); XL_SEL_WIN(7); @@ -651,14 +652,34 @@ xl_rxfilter_90x(struct xl_softc *sc) /* * 3c905B adapters have a hash filter that we can program. + * Note: the 3c905B currently only supports a 64-bit + * hash table, which means we really only need 6 bits, + * but the manual indicates that future chip revisions + * will have a 256-bit hash table, hence the routine + * is set up to calculate 8 bits of position info in + * case we need it some day. + * Note II, The Sequel: _CURRENT_ versions of the + * 3c905B have a 256 bit hash table. This means we have + * to use all 8 bits regardless. On older cards, the + * upper 2 bits will be ignored. Grrrr.... */ +static u_int +xl_check_maddr_90xB(void *arg, struct sockaddr_dl *sdl, u_int count) +{ + struct xl_softc *sc = arg; + uint16_t h; + + h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) & 0xFF; + CSR_WRITE_2(sc, XL_COMMAND, h | XL_CMD_RX_SET_HASH | XL_HASH_SET); + + return (1); +} + static void xl_rxfilter_90xB(struct xl_softc *sc) { struct ifnet *ifp; - struct ifmultiaddr *ifma; - int i, mcnt; - u_int16_t h; + int i; u_int8_t rxfilt; XL_LOCK_ASSERT(sc); @@ -689,31 +710,7 @@ xl_rxfilter_90xB(struct xl_softc *sc) CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH | i); /* Now program new ones. */ - mcnt = 0; - if_maddr_rlock(ifp); - CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { - if (ifma->ifma_addr->sa_family != AF_LINK) - continue; - /* - * Note: the 3c905B currently only supports a 64-bit - * hash table, which means we really only need 6 bits, - * but the manual indicates that future chip revisions - * will have a 256-bit hash table, hence the routine - * is set up to calculate 8 bits of position info in - * case we need it some day. - * Note II, The Sequel: _CURRENT_ versions of the - * 3c905B have a 256 bit hash table. This means we have - * to use all 8 bits regardless. On older cards, the - * upper 2 bits will be ignored. Grrrr.... - */ - h = ether_crc32_be(LLADDR((struct sockaddr_dl *) - ifma->ifma_addr), ETHER_ADDR_LEN) & 0xFF; - CSR_WRITE_2(sc, XL_COMMAND, - h | XL_CMD_RX_SET_HASH | XL_HASH_SET); - mcnt++; - } - if_maddr_runlock(ifp); - if (mcnt > 0) + if (if_foreach_llmaddr(sc->xl_ifp, xl_check_maddr_90xB, sc) > 0) rxfilt |= XL_RXFILTER_MULTIHASH; }