Convert to if_foreach_llmaddr() KPI.

This commit is contained in:
glebius 2019-10-21 18:06:26 +00:00
parent faba9462d8
commit e2629a827f

View File

@ -1621,33 +1621,32 @@ bge_setpromisc(struct bge_softc *sc)
BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_RX_PROMISC);
}
static u_int
bge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
{
uint32_t *hashes = arg;
int h;
h = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0x7F;
hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
return (1);
}
static void
bge_setmulti(struct bge_softc *sc)
{
if_t ifp;
int mc_count = 0;
uint32_t hashes[4] = { 0, 0, 0, 0 };
int h, i, mcnt;
unsigned char *mta;
int i;
BGE_LOCK_ASSERT(sc);
ifp = sc->bge_ifp;
mc_count = if_multiaddr_count(ifp, -1);
mta = malloc(sizeof(unsigned char) * ETHER_ADDR_LEN *
mc_count, M_DEVBUF, M_NOWAIT);
if(mta == NULL) {
device_printf(sc->bge_dev,
"Failed to allocated temp mcast list\n");
return;
}
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) {
for (i = 0; i < 4; i++)
CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0xFFFFFFFF);
free(mta, M_DEVBUF);
return;
}
@ -1655,17 +1654,10 @@ bge_setmulti(struct bge_softc *sc)
for (i = 0; i < 4; i++)
CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0);
if_multiaddr_array(ifp, mta, &mcnt, mc_count);
for(i = 0; i < mcnt; i++) {
h = ether_crc32_le(mta + (i * ETHER_ADDR_LEN),
ETHER_ADDR_LEN) & 0x7F;
hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
}
if_foreach_llmaddr(ifp, bge_hash_maddr, hashes);
for (i = 0; i < 4; i++)
CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), hashes[i]);
free(mta, M_DEVBUF);
}
static void