Convert to if_foreach_llmaddr() KPI.

This commit is contained in:
Gleb Smirnoff 2019-10-21 18:10:46 +00:00
parent 380a564dc2
commit 5b7a9eab16

View File

@ -427,12 +427,14 @@ atse_stop_locked(struct atse_softc *sc)
return (0);
}
static uint8_t
atse_mchash(struct atse_softc *sc __unused, const uint8_t *addr)
static u_int
atse_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
{
uint8_t x, y;
uint64_t *h = arg;
uint8_t *addr, x, y;
int i, j;
addr = LLADDR(sdl);
x = 0;
for (i = 0; i < ETHER_ADDR_LEN; i++) {
y = addr[i] & 0x01;
@ -440,14 +442,14 @@ atse_mchash(struct atse_softc *sc __unused, const uint8_t *addr)
y ^= (addr[i] >> j) & 0x01;
x |= (y << i);
}
*h |= (1 << x);
return (x);
return (1);
}
static int
atse_rxfilter_locked(struct atse_softc *sc)
{
struct ifmultiaddr *ifma;
struct ifnet *ifp;
uint32_t val4;
int i;
@ -478,22 +480,13 @@ atse_rxfilter_locked(struct atse_softc *sc)
*/
uint64_t h;
h = 0;
/*
* Re-build and re-program hash table. First build the
* bit-field "yes" or "no" for each slot per address, then
* do all the programming afterwards.
*/
if_maddr_rlock(ifp);
CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
if (ifma->ifma_addr->sa_family != AF_LINK) {
continue;
}
h |= (1 << atse_mchash(sc,
LLADDR((struct sockaddr_dl *)ifma->ifma_addr)));
}
if_maddr_runlock(ifp);
h = 0;
(void)if_foreach_llmaddr(ifp, atse_hash_maddr, &h);
for (i = 0; i <= MHASH_LEN; i++) {
CSR_WRITE_4(sc, MHASH_START + i,
(h & (1 << i)) ? 0x01 : 0x00);