Convert to if_foreach_llmaddr() KPI.

This commit is contained in:
Gleb Smirnoff 2019-10-21 18:11:32 +00:00
parent 36581f8254
commit 57cc02c62e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=353846

View File

@ -974,13 +974,24 @@ ffec_get_hwaddr(struct ffec_softc *sc, uint8_t *hwaddr)
}
}
static u_int
ffec_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
{
uint64_t *ghash = arg;
uint32_t crc;
/* 6 bits from MSB in LE CRC32 are used for hash. */
crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
*ghash |= 1LLU << (((uint8_t *)&crc)[3] >> 2);
return (1);
}
static void
ffec_setup_rxfilter(struct ffec_softc *sc)
{
struct ifnet *ifp;
struct ifmultiaddr *ifma;
uint8_t *eaddr;
uint32_t crc;
uint64_t ghash, ihash;
FFEC_ASSERT_LOCKED(sc);
@ -994,16 +1005,7 @@ ffec_setup_rxfilter(struct ffec_softc *sc)
ghash = 0xffffffffffffffffLLU;
else {
ghash = 0;
if_maddr_rlock(ifp);
CK_STAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
/* 6 bits from MSB in LE CRC32 are used for hash. */
crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
ifma->ifma_addr), ETHER_ADDR_LEN);
ghash |= 1LLU << (((uint8_t *)&crc)[3] >> 2);
}
if_maddr_runlock(ifp);
if_foreach_llmaddr(ifp, ffec_hash_maddr, &ghash);
}
WR4(sc, FEC_GAUR_REG, (uint32_t)(ghash >> 32));
WR4(sc, FEC_GALR_REG, (uint32_t)ghash);