aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/vge
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2019-10-21 18:08:12 +0000
committerGleb Smirnoff <glebius@FreeBSD.org>2019-10-21 18:08:12 +0000
commit44a30c622499afe20353562688596bc4ebcaffc9 (patch)
tree68724c53eca51baa39a9819d87e585298cb52148 /sys/dev/vge
parent0407b8bf7ad57b8b639b34b70a2676fc444cc289 (diff)
downloadsrc-44a30c622499afe20353562688596bc4ebcaffc9.tar.gz
src-44a30c622499afe20353562688596bc4ebcaffc9.zip
Convert to if_foreach_llmaddr() KPI.
Notes
Notes: svn path=/head/; revision=353831
Diffstat (limited to 'sys/dev/vge')
-rw-r--r--sys/dev/vge/if_vge.c58
1 files changed, 33 insertions, 25 deletions
diff --git a/sys/dev/vge/if_vge.c b/sys/dev/vge/if_vge.c
index e5c7f0cea3f6..962dc73b3039 100644
--- a/sys/dev/vge/if_vge.c
+++ b/sys/dev/vge/if_vge.c
@@ -529,6 +529,34 @@ vge_setvlan(struct vge_softc *sc)
CSR_WRITE_1(sc, VGE_RXCFG, cfg);
}
+static u_int
+vge_set_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+ struct vge_softc *sc = arg;
+
+ if (sc->vge_camidx == VGE_CAM_MAXADDRS)
+ return (0);
+
+ (void )vge_cam_set(sc, LLADDR(sdl));
+
+ return (1);
+}
+
+static u_int
+vge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+ uint32_t h, *hashes = arg;
+
+ h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+ if (h < 32)
+ hashes[0] |= (1 << h);
+ else
+ hashes[1] |= (1 << (h - 32));
+
+ return (1);
+}
+
+
/*
* Program the multicast filter. We use the 64-entry CAM filter
* for perfect filtering. If there's more than 64 multicast addresses,
@@ -538,10 +566,8 @@ static void
vge_rxfilter(struct vge_softc *sc)
{
struct ifnet *ifp;
- struct ifmultiaddr *ifma;
- uint32_t h, hashes[2];
+ uint32_t hashes[2];
uint8_t rxcfg;
- int error = 0;
VGE_LOCK_ASSERT(sc);
@@ -572,33 +598,15 @@ vge_rxfilter(struct vge_softc *sc)
}
vge_cam_clear(sc);
+
/* Now program new ones */
- if_maddr_rlock(ifp);
- CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- error = vge_cam_set(sc,
- LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
- if (error)
- break;
- }
+ if_foreach_llmaddr(ifp, vge_set_maddr, sc);
/* If there were too many addresses, use the hash filter. */
- if (error) {
+ if (sc->vge_camidx == VGE_CAM_MAXADDRS) {
vge_cam_clear(sc);
-
- CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
- if (ifma->ifma_addr->sa_family != AF_LINK)
- continue;
- h = ether_crc32_be(LLADDR((struct sockaddr_dl *)
- ifma->ifma_addr), ETHER_ADDR_LEN) >> 26;
- if (h < 32)
- hashes[0] |= (1 << h);
- else
- hashes[1] |= (1 << (h - 32));
- }
+ if_foreach_llmaddr(ifp, vge_hash_maddr, hashes);
}
- if_maddr_runlock(ifp);
done:
if (hashes[0] != 0 || hashes[1] != 0)