svn commit: r365386 - stable/12/sys/dev/dwc
Oleksandr Tymoshenko
gonzo at FreeBSD.org
Sun Sep 6 18:27:37 UTC 2020
Author: gonzo
Date: Sun Sep 6 18:27:36 2020
New Revision: 365386
URL: https://svnweb.freebsd.org/changeset/base/365386
Log:
MFC r353843 by glebius:
Convert to if_foreach_llmaddr() KPI.
Modified:
stable/12/sys/dev/dwc/if_dwc.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/dev/dwc/if_dwc.c
==============================================================================
--- stable/12/sys/dev/dwc/if_dwc.c Sun Sep 6 18:25:50 2020 (r365385)
+++ stable/12/sys/dev/dwc/if_dwc.c Sun Sep 6 18:27:36 2020 (r365386)
@@ -581,13 +581,37 @@ bitreverse(uint8_t x)
return (nibbletab[x & 0xf] << 4) | nibbletab[x >> 4];
}
+struct dwc_hash_maddr_ctx {
+ struct dwc_softc *sc;
+ uint32_t hash[8];
+};
+
+static u_int
+dwc_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+ struct dwc_hash_maddr_ctx *ctx = arg;
+ uint32_t crc, hashbit, hashreg;
+ uint8_t val;
+
+ crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
+ /* Take lower 8 bits and reverse it */
+ val = bitreverse(~crc & 0xff);
+ if (ctx->sc->mactype == DWC_GMAC_ALT_DESC)
+ val >>= 2; /* Only need lower 6 bits */
+ hashreg = (val >> 5);
+ hashbit = (val & 31);
+ ctx->hash[hashreg] |= (1 << hashbit);
+
+ return (1);
+}
+
static void
dwc_setup_rxfilter(struct dwc_softc *sc)
{
- struct ifmultiaddr *ifma;
+ struct dwc_hash_maddr_ctx ctx;
struct ifnet *ifp;
- uint8_t *eaddr, val;
- uint32_t crc, ffval, hashbit, hashreg, hi, lo, hash[8];
+ uint8_t *eaddr;
+ uint32_t ffval, hi, lo;
int nhash, i;
DWC_ASSERT_LOCKED(sc);
@@ -601,27 +625,13 @@ dwc_setup_rxfilter(struct dwc_softc *sc)
if ((ifp->if_flags & IFF_ALLMULTI) != 0) {
ffval = (FRAME_FILTER_PM);
for (i = 0; i < nhash; i++)
- hash[i] = ~0;
+ ctx.hash[i] = ~0;
} else {
ffval = (FRAME_FILTER_HMC);
for (i = 0; i < nhash; i++)
- hash[i] = 0;
- if_maddr_rlock(ifp);
- CK_STAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
- ifma->ifma_addr), ETHER_ADDR_LEN);
-
- /* Take lower 8 bits and reverse it */
- val = bitreverse(~crc & 0xff);
- if (sc->mactype == DWC_GMAC_ALT_DESC)
- val >>= nhash; /* Only need lower 6 bits */
- hashreg = (val >> 5);
- hashbit = (val & 31);
- hash[hashreg] |= (1 << hashbit);
- }
- if_maddr_runlock(ifp);
+ ctx.hash[i] = 0;
+ ctx.sc = sc;
+ if_foreach_llmaddr(ifp, dwc_hash_maddr, &ctx);
}
/*
@@ -641,11 +651,11 @@ dwc_setup_rxfilter(struct dwc_softc *sc)
WRITE4(sc, MAC_ADDRESS_HIGH(0), hi);
WRITE4(sc, MAC_FRAME_FILTER, ffval);
if (sc->mactype == DWC_GMAC_ALT_DESC) {
- WRITE4(sc, GMAC_MAC_HTLOW, hash[0]);
- WRITE4(sc, GMAC_MAC_HTHIGH, hash[1]);
+ WRITE4(sc, GMAC_MAC_HTLOW, ctx.hash[0]);
+ WRITE4(sc, GMAC_MAC_HTHIGH, ctx.hash[1]);
} else {
for (i = 0; i < nhash; i++)
- WRITE4(sc, HASH_TABLE_REG(i), hash[i]);
+ WRITE4(sc, HASH_TABLE_REG(i), ctx.hash[i]);
}
}
More information about the svn-src-stable-12
mailing list